hashicorp / packer-plugin-virtualbox

Packer plugin for VritualBox Builder
https://www.packer.io/docs/builders/virtualbox
Mozilla Public License 2.0
22 stars 35 forks source link

SATA optical drives mount in the wrong order #20

Closed lamawithonel closed 3 years ago

lamawithonel commented 3 years ago

Overview of the Issue

I use the ISO builder with cd_files and guest_additions_mode = "attach", creating three optical drives. Prior to 1.7 this worked, booting into the install DVD, but after a recent upgrade my Windows 10 installer stopped working. On closer inspection I noticed the Windows ISO refused to boot, because it was not the first optical drive.

Per the documentation, "...the [extra] CD is attached as the second CD device," which I have always understood to imply that the iso_url disk should be first, and the guest additions last. My inspection showed, however, in v1.7.2, the cd_files disk is installed on SATA port 13, the Guest Additions CD on port 14, and the iso_url disk on port 15. For reference, in v1.6.6, my last known good version, the iso_url disk is installed on SATA port 1, the Guest Additions CD on port 2, and the cd_files CD on port 3.

I was able to work around the immediate problem of not booting into the installer by stopping the VM, reordering the drives, rebooting, and manually entering my boot_commands. I have not yet tried using vboxmanage commands to reorder things, but I suspect that will be my interim solution.

Reproduction Steps

Create a template using the VirtualBox-ISO builder, setting both cd_files and guest_additions_mode = "attach". Start the build and inspect the VM's SATA drives.

Plugin and Packer version

$ packer version
Packer v1.7.2

Simplified Packer Buildfile

packer {
    required_version = "= 1.7.2"
    required_plugins {
        virtualbox = {
        version = "= 0.0.1"
        source  = "github.com/hashicorp/virtualbox"
    }
  }
}

build {
    source "source.virtualbox-iso.windows-10" {
        guest_os_type = "Windows10_64"

        iso_interface = "sata"

        vboxmanage = [
            ["modifyvm", "{{.Name}}", "--firmware", "EFI"]
        ]

        iso_url = "/Users/alice/Downloads/en_windows_10_enterprise_ltsc_2019_x64_dvd.iso"
        cd_files = ["cd/touched.file"]
        guest_additions_mode = "attach"
   }
}

Operating system and Environment details

macOS Catalina 10.15.7

$ uname -v
Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64

Log Fragments and crash.log files

2021/04/26 19:47:31 ui: ==> base.virtualbox-iso.atm-windows-10-base: Mounting ISOs...
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting boot ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "15", "--device", "0", "--type", "dvddrive", "--medium", "/Users/alice/Downloads/en_windows_10_enterprise_ltsc_2019_x64_dvd.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting cd_files ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "13", "--device", "0", "--type", "dvddrive", "--medium", "/private/var/folders/sm/h0wmfgys66g6pv2_g6nbbvr40000gq/T/packer537259108.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:
2021/04/26 19:47:31 ui:     base.virtualbox-iso.atm-windows-10-base: Mounting guest additions ISO...
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 Executing VBoxManage: []string{"storageattach", "packer-windows-10-1619480840", "--storagectl", "SATA Controller", "--port", "14", "--device", "0", "--type", "dvddrive", "--medium", "/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso"}
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stdout:
2021/04/26 19:47:31 packer-plugin-virtualbox_v0.0.1_x5.0_darwin_amd64 plugin: 2021/04/26 19:47:31 stderr:
ciarancourtney commented 3 years ago

@lamawithonel I'm pretty sure this was introduced in 1.7.1, namely GH-10674 in https://github.com/hashicorp/packer/blob/master/CHANGELOG.md#improvements-2

I'm having the same issue, but with Linux using EFI.