以下是VirtualBox在Ubuntu上的命令行操作方法:
安裝VirtualBox
sudo apt update
sudo apt install virtualbox
創建虛擬機
VBoxManage createvm --name "UbuntuVM" --ostype "Ubuntu_64" --register
配置虛擬機
VBoxManage modifyvm "UbuntuVM" --memory 2048
VBoxManage createhd --filename "UbuntuVM.vdi" --size 20000
VBoxManage storagectl "UbuntuVM" --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach "UbuntuVM" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "UbuntuVM.vdi"
啟動/關閉虛擬機
VBoxManage startvm "UbuntuVM"
VBoxManage controlvm "UbuntuVM" poweroff
其他常用操作
VBoxManage list vms
VBoxManage unregistervm "UbuntuVM" --delete
說明:需先安裝VirtualBox擴展包以支持命令行工具VBoxManage,部分操作(如網絡配置)需結合圖形界面或額外參數。