安装操作系统后,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 才能运行 VM?

答案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

相关内容