Virtualbox 在安裝作業系統後需要 ISO 來啟動虛擬機

Virtualbox 在安裝作業系統後需要 ISO 來啟動虛擬機

由於某種原因,在我創建新的虛擬機器並為其安裝作業系統後,安裝完成後它會停止啟動。我必須重新掛載用於安裝的 ISO 才能使虛擬機器正常運作。 Virtualbox 是最新版本,iso 是預設的 Windows 7 SP1 x64。我透過命令列批次檔建立虛擬機器:

REM Create Entry:
VBoxManage createvm -name "Windows 7 - For Testing Purposes Only" -ostype Windows7_64 --register

REM Create Drive:
VBoxManage createhd --filename "D:\Virtual Machines\7HD" --size 12288 --format VHD

REM Add Controllers:
VBoxManage storagectl "Windows 7 - For Testing Purposes Only"  --name "SATA Controller" --add sata --sataportcount 2 --hostiocache on --bootable on

REM Attach to Controllers:
VBoxManage storageattach "Windows 7 - For Testing Purposes Only" --storagectl "SATA Controller" --port 0 --type hdd --medium "D:\Virtual Machines\7HD.vhd"
VBoxManage storageattach "Windows 7 - For Testing Purposes Only" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium emptydrive

REM Set VM Parameters:
VBoxManage modifyvm "Windows 7 - For Testing Purposes Only" --memory 4096 --vram 130 --cpus 4 --accelerate3d on --boot1 dvd --boot2 none --boot3 none --boot4 none --usb on --usbehci on --audio dsound --audiocontroller hda --nic1 bridged --bridgeadapter1 "Realtek RTL8139/810x Family Fast Ethernet NIC" --bioslogodisplaytime 1 --biosbootmenu menuonly --largepages on

REM Add Shared folders from host:
VBoxManage sharedfolder add "Windows 7 - For Testing Purposes Only" --name "C_DRIVE" --hostpath C:\ --automount
VBoxManage sharedfolder add "Windows 7 - For Testing Purposes Only" --name "D_DRIVE" --hostpath D:\ --automount
VBoxManage sharedfolder add "Windows 7 - For Testing Purposes Only" --name "K_DRIVE" --hostpath K:\ --automount
VBoxManage sharedfolder add "Windows 7 - For Testing Purposes Only" --name "Q_DRIVE" --hostpath Q:\ --automount

REM Create Shortcut for the new VM on desktop:
copy NUL %temp%\CreateWVVMShortcut.vbs
echo Set Shell = CreateObject("WScript.Shell")>>%temp%\CreateWVVMShortcut.vbs
echo DesktopPath = Shell.SpecialFolders("Desktop")>>%temp%\CreateWVVMShortcut.vbs
echo Set link = Shell.CreateShortcut(DesktopPath ^& "\Windows 7 TEST.lnk")>>%temp%\CreateWVVMShortcut.vbs
echo link.Arguments = "-startvm ""Windows 7 - For Testing Purposes Only""">>%temp%\CreateWVVMShortcut.vbs
echo link.IconLocation = "%ProgramW6432%\Oracle\VirtualBox\VirtualBox.exe,0">>%temp%\CreateWVVMShortcut.vbs
echo link.TargetPath = "%ProgramW6432%\Oracle\VirtualBox\VirtualBox.exe">>%temp%\CreateWVVMShortcut.vbs
echo link.WorkingDirectory = "%ProgramW6432%\Oracle\VirtualBox">>%temp%\CreateWVVMShortcut.vbs
echo link.Save>>%temp%\CreateWVVMShortcut.vbs
cscript //nologo %temp%\CreateWVVMShortcut.vbs

REM Run new VM:
VBoxManage startvm "Windows 7 - For Testing Purposes Only" --type gui

我是否做錯了什麼,或者您需要始終安裝 ISO 來運行虛擬機,這是預期的行為嗎?

答案1

我能夠透過命令列使用 [ --tempeject on] 啟用“Live CD/DVD”,方法如下:

VBoxManage.exe storageattach %VM_NAME% --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --tempeject on --medium %VBOX_HOME%\VBoxGuestAdditions.iso

相關內容