Building a Windows 7 VM

3,761 views
Skip to first unread message

Harsh Desai

unread,
Aug 23, 2013, 7:24:08 PM8/23/13
to packe...@googlegroups.com
Hi

I am trying to build a windows 7 VM using packer build. Following is my json template which I was able to validate successfully.

{
  "builders": [{
  "vm_name" : "win7-packer",
  "type": "vmware",
  "guest_os_type": "Windows7_64",
  "iso_url": "/home/hdesai/en_windows_7_professional_n_with_sp1_x86_dvd_624000.iso",
  "iso_checksum": "27b4eef1c1abf8ba5d4ad3c7a4e14586",
  "iso_checksum_type": "md5",
  "ssh_username": "dev",
  "ssh_wait_timeout": "30s"
  }]
}

However, I get a vmware executable file not found in $PATH. In the documentation, I could not find a step that I missed about installing the vmware executable and adding it to PATH. What did I miss?

$ packer build win7.json 
vmware output will be in this color.

Build 'vmware' errored: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors
from each driver are shown below. Please fix at least one driver
to continue:
* exec: "vmware": executable file not found in $PATH
* VMware Player application ('vmplayer') not found in path.


==> Some builds didn't complete successfully and had errors:
--> vmware: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors
from each driver are shown below. Please fix at least one driver
to continue:
* exec: "vmware": executable file not found in $PATH
* VMware Player application ('vmplayer') not found in path.


==> Builds finished but no artifacts were created.

Thanks
Harsh

Harsh Desai

unread,
Aug 23, 2013, 7:51:48 PM8/23/13
to packe...@googlegroups.com
After installing VMware player, I now get

[~/packer/templates/windows|windows]$ packer build win7.json 
vmware output will be in this color.

Build 'vmware' errored: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors
from each driver are shown below. Please fix at least one driver
to continue:
* exec: "vmware": executable file not found in $PATH
* Critical application 'vmrun' not found in path.


==> Some builds didn't complete successfully and had errors:
--> vmware: Failed creating VMware driver: Unable to initialize any driver for this platform. The errors
from each driver are shown below. Please fix at least one driver
to continue:
* exec: "vmware": executable file not found in $PATH
* Critical application 'vmrun' not found in path.


==> Builds finished but no artifacts were created.



Julian Phillips

unread,
Aug 23, 2013, 8:06:18 PM8/23/13
to packe...@googlegroups.com
On 24/08/2013 00:51, Harsh Desai wrote:
> After installing VMware player, I now get
>
> [~/packer/templates/windows|windows]$ packer build win7.json
> vmware output will be in this color.
>
> Build 'vmware' errored: Failed creating VMware driver: Unable to
> initialize
> any driver for this platform. The errors
> from each driver are shown below. Please fix at least one driver
> to continue:
> * exec: "vmware": executable file not found in $PATH
> * Critical application 'vmrun' not found in path.

If you want to use VMware Player then you need "VMware VIX API" (from
the Player download page) installed to give you vmrun. You also need
either the VMware VDDK (for vmware-vdiskmanager, this is available from
the VMware site, but you have to dig it out) or qemu-img so that packer
can manipulate .vmdk files.

VMware Workstation includes all the needed tools in the main installer.

--
Julian

Harsh Desai

unread,
Aug 23, 2013, 8:46:40 PM8/23/13
to packe...@googlegroups.com
Thanks Julian,

I installed VIX and qemu. The build ahead and I was able to install windows 7. During the whole time, packer was waiting at the "Waiting for SSH to become available" stage. Once the Windows 7 VM was up, packer error saying "errored waiting for SSH".

If I am right, a windows VM will not have SSH daemon installed by default. So how can packer wait for SSH to become available?

[~/packer/templates/windows|windows]$ packer build win7-32.json 
vmware output will be in this color.

==> vmware: Downloading or copying ISO
    vmware: Downloading or copying: file:///mnt/netstore/eng/OS_ISOs/Microsoft/Win7/en_windows_7_professional_n_with_sp1_x86_dvd_624000.iso
==> vmware: Creating virtual machine disk
==> vmware: Building and writing VMX file
==> vmware: Starting virtual machine...
==> vmware: Waiting 10s for boot...
==> vmware: Connecting to VM via VNC
==> vmware: Typing the boot command over VNC...
==> vmware: Waiting for SSH to become available...
==> vmware: Timeout waiting for SSH.
==> vmware: Stopping virtual machine...
==> vmware: Deleting output directory...
Build 'vmware' errored: Build was halted.

==> Some builds didn't complete successfully and had errors:
--> vmware: Build was halted.

==> Builds finished but no artifacts were created.

Thanks
Harsh

mi...@misheska.com

unread,
Aug 27, 2013, 6:04:10 AM8/27/13
to packe...@googlegroups.com
Yes, you have to also add a script that bootstraps the SSH daemon on the Windows image in your template definition.

Take a look at my Windows 7 template for an example.  This successfully generates a Windows 7 image with Packer by bootstrapping a Cygwin SSH server on the image:

The only issue I've encountered (beyond the trouble to have to configure an SSH server on Windows), is that vagrant ignores the config.vm.guest setting informing it is running windows (which I've reported as an issue: https://github.com/mitchellh/vagrant/issues/2057 ).  This makes it impossible for me to use some tools like Opscode Chef's Test Kitchen who refuse to run when vagrant reports the error "The guest operating system of the machine could not be detected", but is otherwise benign.

Hopefully at some point Packer will support the winrm protocol in addition to SSH, which would be a better choice for Windows.  This is currently supported by alternative image-building tool to Packer - Veewee.  Unfortunately it's a bit of trouble to setup the vagrant-windows plugin needed to get vagrant to use winrm: https://github.com/WinRb/vagrant-windows  You will have to build the plugin yourself using the "vagrant-1.2" branch instead of using the convenient "vagrant plugin install" command (though unlike what the documentation says, the plugin does work with vagrant 1.2.x, if you use the latest branch).

Harsh Desai

unread,
Aug 27, 2013, 6:05:44 PM8/27/13
to packe...@googlegroups.com
The templates were very useful ! 

Are you executing this (make vmware/misheska-win7x64.box) from a windows machine?

I tried to build the windows template and it errored complaning about vmware tools. This would mean, packer could not find vmware tools for windows on my local machine from where I am executing make. I am running packer from an ubuntu workstation.

Build 'vmware' errored: Couldn't find VMware tools for 'windows'! VMware often downloads these
tools on-demand. However, to do this, you need to create a fake VM
of the proper type then click the 'install tools' option in the
VMware GUI.

~Harsh

Harsh Desai

unread,
Aug 27, 2013, 9:59:51 PM8/27/13
to packe...@googlegroups.com
SSH handshake is failing for me. 
Cygwin was installed and a ps showed that the sshd is indeed running. How can I debug this more?

=> vmware: Downloading or copying ISO
    vmware: Downloading or copying: file:///mnt/netstore/eng/OS_ISOs/Microsoft/Win7/en_windows_7_professional_n_with_sp1_x86_dvd_624000.iso
==> vmware: Creating floppy disk...
    vmware: Copying: Autounattend.xml
    vmware: Copying: set-power-config.bat
    vmware: Copying: install-cygwin-sshd.bat
==> vmware: Creating virtual machine disk
==> vmware: Building and writing VMX file
==> vmware: Starting virtual machine...
==> vmware: Waiting 10s for boot...
==> vmware: Connecting to VM via VNC
==> vmware: Typing the boot command over VNC...
==> vmware: Waiting for SSH to become available...
==> vmware: Error waiting for SSH: handshake failed: ssh: unable to authenticate, attempted methods [none password keyboard-interactive], no supported methods remain
==> vmware: Stopping virtual machine...
==> vmware: Deleting output directory...
Build 'vmware' errored: Build was halted.

mi...@misheska.com

unread,
Aug 28, 2013, 2:22:17 AM8/28/13
to packe...@googlegroups.com
More than likely you have the firewall turned on in your Windows 7 image.  Did you reuse my Autounattend.xml to build your Windows 7?  If not, it is something to consider - not only do you need to bootstrap Cygwin, but you also need to open up port 22 on the image for ssh.

I've written a blog post with more detail on customizing your own Autounattend.xml, if you need it: http://misheska.com/blog/2013/07/26/windows-7-automated-install-settings/

mi...@misheska.com

unread,
Aug 28, 2013, 2:27:02 AM8/28/13
to packe...@googlegroups.com
P.S. To troubleshoot, just launch the Windows 7 image in a VM and check the firewall settings (outside of packer).  Bootstrap cygwin and try ssh'ing to localhost and verify that works (username/password is vagrant/vagrant).  Once you get all that working and automated, the packer install should work.

You can also try sshing outside the image by running "ipconfig" to get the 192.xxx.xxx.xxx address vagrant assigns and verify that ssh works that way, but I've found that once I've tested it inside the image with localhost, I rarely have issues outside the image.

mi...@misheska.com

unread,
Aug 28, 2013, 2:31:06 AM8/28/13
to packe...@googlegroups.com
P.P.S. Key is that your Autounattend run something like I have in the install-cygwin-sshd.bat script:

You'll notice the commands to add a firewall rule midway:
cmd /c if exist %Systemroot%\system32\netsh.exe netsh advfirewall firewall add rule name="SSHD" dir=in action=allow program="c:\cygwin\usr\sbin\sshd.exe" SSHD enable=yes

cmd /c if exist %Systemroot%\system32\netsh.exe netsh advfirewall firewall add rule name="ssh" dir=in action=allow protocol=TCP localport=22

Make sure those are running within your image when you build it.  To start, I ran these commands by hand so I could troubleshoot and understand how everything worked.


On Friday, August 23, 2013 4:24:08 PM UTC-7, Harsh Desai wrote:

mi...@misheska.com

unread,
Aug 28, 2013, 2:36:37 AM8/28/13
to packe...@googlegroups.com
Oh, also, looking more carefully at your json, you don't list an ssh_password.  Make sure that account exists and it has no password.  I haven't tried using a blank password with cygwin - I'm not sure if that might work.  That could be another issue (which you can sort out by trying it locally within the image)...


On Friday, August 23, 2013 4:24:08 PM UTC-7, Harsh Desai wrote:

Harsh Desai

unread,
Aug 28, 2013, 10:00:05 PM8/28/13
to packe...@googlegroups.com
I was able to get it working. I looked at your template and unattend file to serve as a reference. 

Is there a way to add multiple disks using the vmware builder? I don't see any way to do that right now.

Thanks !

zwevans

unread,
Aug 28, 2013, 11:21:30 PM8/28/13
to packe...@googlegroups.com
Thank you so much for posting these responses.  I found this thread at just the right time and it is quite helpful...and feel like I'm getting close to a working W7 VM.  One sticking point has been the cygwin installation.  The script in the repo you linked attempts to download from http://www.cygwin.com/setup.exe which seems to be a broken link now.  Changing it to http://www.cygwin.com/setup-x86_64.exe allows the download to complete, but the installation fails when trying to included packages.  I haven't been able to get '--quiet-mode' to work with '--packages' on the install.  The setup exits without completing unless I remove '--quiet-mode' OR remove the '--packages' option.

Are you guys able to run the command as is right now with success?  Thanks again for sharing the previous info!

Thanks,

Zach
Message has been deleted

Harsh Desai

unread,
Aug 29, 2013, 2:37:05 PM8/29/13
to packe...@googlegroups.com
Change the path to http://www.cygwin.com/setup-x86.exe. It works on a 64-bit box too.

If you really want a 64 bit cygwin installation, the script will need some change since it was written for a x86 install.

~Harsh

zwevans

unread,
Aug 31, 2013, 7:04:27 AM8/31/13
to packe...@googlegroups.com
Thank you.  Changed the download path to use the 32 bit version and I'm back in business.  Still can't get the 64bit version to work....but I don't think that is necessary at this point.  Glad to be moving forward again.

-Zach

Harsh Desai

unread,
Sep 25, 2013, 8:08:30 PM9/25/13
to packe...@googlegroups.com
Hi Zach,

Suddenly my cygwin install script has stopped working. During the cygwin installation, a pop up opens saying cygintl-8.dll is missing from your computer, hence cygwin installation cannot continue.

Are you seeing this too?

Thanks
Harsh

zwevans

unread,
Sep 27, 2013, 9:12:54 PM9/27/13
to packe...@googlegroups.com
Hey Harsh.  I can confirm that I am also seeing this new error.  Haven't dug in yet.  Any leads so far?

-Zach

zwevans

unread,
Oct 3, 2013, 10:43:46 PM10/3/13
to packe...@googlegroups.com
Hi Harsh,

As a minor update... I got past the cygintl-8.dll error by adding libintl8 as a package to install during cygwin installation.  After that, a new error suggests cygiconv-2.dll is missing.  I found a seemingly related package, libiconv and attempted to add that as a package the same way as libintl8.  No luck.  Still failing with cygiconv-2.dll missing...

-Zach

mi...@misheska.com

unread,
Oct 21, 2013, 7:22:18 PM10/21/13
to packe...@googlegroups.com
You can find working Win7 templates in my packer template repo that work with the new Cygwin:

Ross Smith contributed changes to make the cygwin install work with the latest cygwin changes.
Reply all
Reply to author
Forward
0 new messages