packer-plugin-virtualbox icon indicating copy to clipboard operation
packer-plugin-virtualbox copied to clipboard

If guest_additions_mode is attach and device gets lower "ID" on the IDE/SATA bus than ISO, VM fails to boot

Open dragon788 opened this issue 3 years ago • 0 comments

Overview of the Issue

Trying to create a Windows 10 VM fails with "FATAL: Could not read from the boot medium! System halted." When looking at the hardware configuration in the Virtualbox UI, it appears the VboxAdditions ISO gets added with a lower ID than the Windows ISO which results in a higher "boot priority" in the DVD category, and so Virtualbox tries to boot from a non-OS ISO and fails, hanging the build.

Switching the type to upload allows it to proceed but takes FOREVER and I've had it intermittently fail for no apparent reason.

I wondered if perhaps setting the tools interface to IDE could work around the issue, or enabling EFI boot instead. I tried both, and it turns out the "fix" is to set the iso_interface to ide and leave the guest_additions_interface as the default (which the docs say is ide, but actually appears to be sata), because IDE apparently gets priority over sata in the boot order evaluation so the Windows ISO boots successfully. This fix also allows EFI to boot properly, where without the workaround you got a slightly less scary EFI prompt instead of the FATAL error message, but if you watched closely, it does actually prompt to "press any key to boot from DVD" where for non-EFI aka BIOS mode you never get that prompt, but interacting with the VM to launch the boot defeats the purpose of Packer's automated process.

Recorded this issue and this workaround in the chef/bento repository I was using when I discovered the issue. https://github.com/chef/bento/issues/1370

Reproduction Steps

git clone https://github.com/chef/bento chef-bento-packer-templates
cd chef-bento-packer-templates/packer_templates/windows
packer build --only virtualbox-iso windows-10.json

Functional workaround

https://github.com/chef/bento/blob/252830cfe3a38ed5ba217464c1209625b9a3691c/packer_templates/windows/windows-10.json#L32-L40

Changed iso_interface: ide

Added guest_additions_interface: sata It appears that the guest additions gets added as a "secondary device" if left to the default IDE, whether that is an additional IDE bus or just as a slave while the OS ISO is master, it fails to boot in EFI mode but oddly not BIOS mode because it is "port 0" and the OS ISO is "port 1" and Virtualbox's BIOS/EFI implementation doesn't attempt additional devices automatically (or in EFI requires a user keypress).

Plugin and Packer version

1.7.4

Simplified Packer Buildfile

https://github.com/chef/bento/blob/252830cfe3a38ed5ba217464c1209625b9a3691c/packer_templates/windows/windows-10.json

Operating system and Environment details

macOS 11.5.1 host Virtualbox 6.1.26

Log Fragments and crash.log files

BIOS with guest as IDE and OS ISO as ide Succeeds (usually)

OS ISO as sata, guest additions as sata, FAILS. image

OS ISO as sata, guest additions as default IDE FAILS. Screen Shot 2021-09-02 at 10 59 29 AM

EFI with guest as IDE and OS ISO as ide or sata, FAILS. Screen Shot 2021-09-02 at 10 53 05 AM

dragon788 avatar Sep 02 '21 16:09 dragon788