Packer build of a virtualbox windows 7 ISO hangs

3

3

When I am building a win 7 box using packer, it hangs waiting for SSH to be available:

==> virtualbox-iso: Downloading or copying Guest additions
    virtualbox-iso: Downloading or copying: file:///vb/VBoxGuestAdditions.iso
==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: file:///home/foo/win7_prof.iso
==> virtualbox-iso: Creating floppy disk...
    virtualbox-iso: Copying: ./answer_files/7/Autounattend.xml
    virtualbox-iso: Copying: ./scripts/dis-updates.ps1
    virtualbox-iso: Copying: ./scripts/microsoft-updates.bat
    virtualbox-iso: Copying: ./scripts/win-updates.ps1
    virtualbox-iso: Copying: ./scripts/openssh.ps1
    virtualbox-iso: Copying: ./scripts/oracle-cert.cer
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Creating hard drive...
==> virtualbox-iso: Attaching floppy disk...
==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 3143)
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1420575242 --memory 2048
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1420575242 --cpus 2
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 2m0s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...

Any experience with resolving this ?

socgen hacker

Posted 2015-01-06T21:16:43.147

Reputation: 267

Initially I also wondered why it hangs (btw, I'm on Linux). In my case it was working fine (no hangs), but virtualbox was in headless mode and I didn't see any activity. In your template file, try adding "headless": false in virtualbox builder and see what happens. Please report back. – Paolo – 2015-02-15T18:54:59.163

How long do you let it sit at the Waiting for SSH to become available... before you came to the assumption that it's just hung up? – Kuberchaun – 2015-08-21T21:15:25.873

Answers

0

Packer currently requires that an SSH server is installed and running in the guest OS (virtual machine).

Edit Autounattend.xml and add the command that installs OpenSSH. Make sure it's the last command and that the Order is correct.

Reference: https://github.com/joefitzgerald/packer-windows/issues/141#issuecomment-82056372

For an example command and script that installs OpenSSH, see https://github.com/joefitzgerald/packer-windows/blob/master/answer_files/7/Autounattend.xml and https://github.com/joefitzgerald/packer-windows/blob/develop/scripts/openssh.ps1

Rami A.

Posted 2015-01-06T21:16:43.147

Reputation: 113