Unable to upload VMWare Tools to VM

1,819 views
Skip to first unread message

Lucius Bono

unread,
Jul 16, 2015, 12:59:28 PM7/16/15
to packe...@googlegroups.com
I'm really new to Packer and I'm having some issues getting my Windows 8.1 Enterprise Trial VM to build in VMWare Fusion Pro (using the vmware-iso builder). 

Everything appears to be working fine, save for the step where I try to upload VMWare tools (as a .ISO) to the VM so that it can be unpacked and installed. I get no errors during this step, until 7-Zip tries to unpack the ISO and install it. Output looks like this:


vmware-iso: Error: Can not open file as archive



Which just indicates that it can locate the file, but it can't open it. I've watched the file appear in the specified directory, but it has a file-size of 0. 

I've tried both using tools_upload_flavor and tools_upload_path as well as the method I'm currently trying, the file provisioner, and I get the same results.

Scripts are able to upload fine to the VM, and they execute as expected. 

The contents of my .JSON file are as follows:

{
  "builders": [{    
    "type": "vmware-iso",
    "boot_wait": "5m",
    "communicator": "winrm",
    "disk_size": 61440,
    "floppy_files": [
      "autounattend.xml",
      "configure-winrm.ps1"
    ],
    "guest_os_type": "windows8-64",
    "headless": true,
    "iso_url": "/Users/Lucius/ISOs/OSes/Windows81ENT/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_ENTERPRISE_EVAL_EN-US-IR3_CENA_X64FREE_EN-US_DV9.ISO",
    "iso_checksum_type": "md5",
    "iso_checksum": "ee63618e3be220d86b993c1abbcf32eb",
    "winrm_username": "vagrant",
    "winrm_password": "vagrant",
    "winrm_timeout": "4h",
    "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
    "skip_compaction": false,
    "vmx_data": {
      "gui.fitguestusingnativedisplayresolution": "FALSE",
      "memsize": "8192",
      "numvcpus": "4",
      "virtualHW.version": "10",
      "scsi0.virtualDev": "lsisas1068"
    }
  }],
  "provisioners": [
  {
  "type": "file",
  "source": "windows.iso",
  "destination": "c:\\Windows\\Temp\\windows.iso"
  },
  {
    "type": "powershell",
    "scripts": [
      "install-7zip.ps1",
      "install-vmware-tools.ps1"]
  }],
  "post-processors": [
    {
      "type": "vagrant",
      "keep_input_artifact": false,
      "output": "{{.Provider}}_windows-8.1.box"
    }
  ] 
}

Any help would be appreciated! I'm building on OSX into VMWare Fusion Pro 7.1.2, Packer 0.8.1 and the vagrant-vmware-fusion plugin 3.2.9

Blake Garner

unread,
Jul 16, 2015, 4:05:49 PM7/16/15
to packe...@googlegroups.com
Here is what I'm using to upload vmware tools. I can confirm that this works with winrm packer 0.8.1 and Fusion 7.1.2. You might try using forward slash  in the path instead of escaping the backslashes. 

    {
      "type": "file",
      "source": "FILES/setup64.exe",
      "destination": "C:/Windows/Temp/setup64.exe"
    },

Lucius Bono

unread,
Jul 16, 2015, 7:13:59 PM7/16/15
to packe...@googlegroups.com
Hmmmmm that doesn't seem to work for me. new code: 

  "provisioners": [
  {
  "type": "file",
  "source": "setup64.exe",
  "destination": "c:/windows/temp/vmware/setup64.exe"
  },



Leads to a new error:

vmware-iso: Error restoring file from $env:TEMP\winrmcp-55a833bf-b981-55dd-44e6-8d2991140a6f.tmp to c:\windows\temp\vmware\setup64.exe: restore operation returned code=3221225725

Alvaro Miranda Aguilera

unread,
Jul 16, 2015, 9:25:16 PM7/16/15
to packe...@googlegroups.com
On Fri, Jul 17, 2015 at 11:13 AM, Lucius Bono <luciu...@gmail.com> wrote:
> c:/windows/temp/vmware/

Hello

Does c:/windows/temp/vmware/ exist?

Lucius Bono

unread,
Jul 16, 2015, 9:26:58 PM7/16/15
to packe...@googlegroups.com
AH, I didn't realize it needed to pre-exist. I will try that. 

Alvaro Miranda Aguilera

unread,
Jul 16, 2015, 9:33:09 PM7/16/15
to packe...@googlegroups.com
Hi There

yeah, not sure that's the error, but this is on packer documentation
for file provisioner:

destination (string) - The path where the file will be uploaded to in
the machine. This value must be a writable location and any parent
directories must already exist.

https://packer.io/docs/provisioners/file.html
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/5c4d0b35-5d13-42a9-9483-6d3472abf9f9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Lucius Bono

unread,
Jul 17, 2015, 1:45:12 AM7/17/15
to packe...@googlegroups.com
Hmm, still getting errors like this:

==> vmware-iso: Uploading setup64.exe => C:/Windows/Temp/setup64.exe


==> vmware-iso: Upload failed: Error restoring file from $env:TEMP\winrmcp-55a88f5a-0b87-688d-d7e2-4ba4e8cee1c7.tmp to C:\Windows\Temp\setup64.exe: restore operation returned code=1


==> vmware-iso: Stopping virtual machine...


==> vmware-iso: Deleting output directory...


Build 'vmware-iso' errored: Error restoring file from $env:TEMP\winrmcp-55a88f5a-0b87-688d-d7e2-4ba4e8cee1c7.tmp to C:\Windows\Temp\setup64.exe: restore operation returned code=1


So what's the best way to debug a build? I feel like I'm just shooting into the dark. Make a change, get a failure, make a change, get a failure. 

The other odd thing is that the Uploading stage takes an inordinately long amount of time. Upwards of 10 minutes on a brand new rMBP 15" with a very fast SSD. The whole Windows install / build takes about 60 seconds. 

Alvaro Miranda Aguilera

unread,
Jul 17, 2015, 2:02:09 AM7/17/15
to packe...@googlegroups.com
Hello,

Share a zip file with your packer.json and the unattended file, etc..
be sure to not share isos or cd-keys if any

for the packer run, you can do

set PACKER_LOG=1
packer build ......

That will generate a debug log, feel free to share that
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/7fc82090-cb75-4fe5-a3d2-50138f2577bc%40googlegroups.com.

Lucius Bono

unread,
Jul 17, 2015, 2:44:36 AM7/17/15
to packe...@googlegroups.com
Ah, so I found out that some of my errors seem to be due to me not cleaning up the packer_cache directory between builds. I'm still unable to install VMWare Tools. 

I've included the logs of my last build (I didn't wait for it to finish compressing the VMDKs and build the box, but all the important bits should be in it). 

Really appreciate all the help!
windowsbuild.zip
packerlogs.log

Alvaro Miranda Aguilera

unread,
Jul 17, 2015, 6:09:50 AM7/17/15
to packe...@googlegroups.com
Hello There

Disclaimer.. I am oracle dba that does linux.. however I did MS stuff
back in.. nt/2000 :P



How much RAM do you have at the Machine you are running this?

I can see 8gb given to the VM

On the logs I can see this:

VMTools seems to upload ok
2015/07/16 23:11:35 ui: [1;32m==> vmware-iso: Uploading setup64.exe
=> C:/Windows/Temp/setup64.exe [0m
2015/07/16 23:11:35 packer-builder-vmware-iso: 2015/07/16 23:11:35
Uploading file to 'C:/Windows/Temp/setup64.exe'
2015/07/16 23:11:37 packer-provisioner-file: 2015/07/16 23:11:37
[INFO] 47134880 bytes written for 'uploadData'

However there is this memory error:

s" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR
N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil
/><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD>
</SD></PR></MS></Obj><S S="Error">Exception of type
'System.OutOfMemoryException' was thrown._x000D__x000A_</S

And when try to run this, complains the file is not a valid file.


2015/07/16 23:37:38 ui: [0;32m vmware-iso: Program 'setup64.exe'
failed to run: The specified executable is not a valid [0m
2015/07/16 23:37:38 ui: [0;32m vmware-iso: application for this OS
platform.At C:\Windows\Temp\script.ps1:4 char:1 [0m
2015/07/16 23:37:38 ui: [0;32m vmware-iso: +
&c:\windows\temp\setup64.exe /S /v`"/qn REBOOT=R`" | Out-Host [0m


So, I found this url:

https://communities.vmware.com/thread/344569

that state this is due the amount of ram assigned to the powershell shell

and this other url:
https://msdn.microsoft.com/en-us/library/ee309367(v=vs.85).aspx

that state you can't go under the default 1024 for MaxMemoryPerShellMB


and I am confused about your script configure-winrm.ps1
..
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'


So my recomendation will be change that line to 2028 and add a value
for the ps shell to be safe

winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'

...
..
..
<end of the script>
Set-Item wsman:localhost\Shell\MaxMemoryPerShellMB 2048 -Force



and just to be sure, can you md5 setup64.exe and check if the file in
the project and the one you used as source are the same?

I am running a test now, but's taking some time.. will send another
update once it finish..

per your logs you did use OSX + Fusion, so I am using my mac mini to
try to reproduce all

Alvaro
> https://groups.google.com/d/msgid/packer-tool/e9a3014c-f799-49ae-a18c-2eb7caffe960%40googlegroups.com.

Blake Garner

unread,
Jul 17, 2015, 12:51:53 PM7/17/15
to packe...@googlegroups.com
Good catch Alvaro! Lucius you can reference what I'm doing in these links. 

Configure windows for winrm.

The vmware tools install script I'm using but is not working right now. 

Blake

Lucius Bono

unread,
Jul 17, 2015, 5:31:10 PM7/17/15
to packe...@googlegroups.com
Ah, great suggestions everyone. I was just following in the footsteps of other folks' JSON files so setting the PerShell settings all came from other projects. I should've caught that one. 

Still having the same errors after I made the changes though. I'm wondering if my AutoUnattend.xml file has a bunch of rogue settings in it - I also pulled it from another project. 

Alvaro Miranda Aguilera

unread,
Jul 17, 2015, 8:31:04 PM7/17/15
to packe...@googlegroups.com
Hi there

my last nigth run failed for time out.. probably since I have just
16gb of ram and plenty of stuff running.

I did the changes (ram down to 4g, cpu to 2 core), plus what I did
suggest and one more in the Autoattended.xml for the same parameter

if fail, i think I will go to test one of the packer windows, and
check if that work

I understand that you don't actually care use this or other, just get
one working?

not sure if you have tried this:
https://github.com/joefitzgerald/packer-windows

Alvaro
> https://groups.google.com/d/msgid/packer-tool/eab8396b-86e7-4f95-86cb-c77ce497b10b%40googlegroups.com.

Lucius Bono

unread,
Jul 17, 2015, 8:49:10 PM7/17/15
to packe...@googlegroups.com
Thanks so much for all your in-depth analysis Alvaro.

I've seen (and borrowed some of my code) from that project, the reason I'm not using it (or any other project) is that I'm interested in building a nearly-stock Windows 8.1 image for testing, and I would like to use WinRM instead of installing SSH, since Packer supports that now. Plus, I like learning. I feel like I'm really close, I'm just hung up on this one issue!

Lucius Bono

unread,
Jul 17, 2015, 9:48:21 PM7/17/15
to packe...@googlegroups.com
Really stumped on this still! I've gone through my scripts, and my Autounattend.xml. Everything really looks like it should be fine, but I just can't get VMWare tools uploaded to the VM! I've re-zipped the relevant files in case anyone wants to take a look at them. Everything else is working flawlessly (as far as I know!)


Autounattend.xml
configure-winrm.ps1
install-vmware-tools.ps1
packer.json

Alvaro Miranda Aguilera

unread,
Jul 17, 2015, 11:37:29 PM7/17/15
to packe...@googlegroups.com
Hi there,

Packer build:

==> vmware-iso: Connected to WinRM!

==> vmware-iso: Uploading setup64.exe => C:/Windows/Temp/setup64.exe
==> vmware-iso: Provisioning with Powershell...
==> vmware-iso: Provisioning with shell script: install-vmware-tools.ps1
==> vmware-iso: Gracefully halting virtual machine...
    vmware-iso: Waiting for VMware to clean up after itself...
==> vmware-iso: Deleting unnecessary VMware files...

and testing with vagrant

$ vagrant up --provider=vmware_fusion | tee vagrant_up_provider_vmware_fusion.log
Bringing machine 'default' up with 'vmware_fusion' provider...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
==> default: Starting the VMware VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 192.168.177.136:5985
    default: WinRM username: vagrant
    default: WinRM transport: plaintext
==> default: Machine booted and ready!
==> default: Forwarding ports...
    default: -- 5985 => 55985
    default: -- 5986 => 55986
==> default: Configuring network adapters within the VM...
==> default: Configuring secondary network adapters through VMware 
==> default: on Windows is not yet supported. You will need to manually
==> default: configure the network adapter.
==> default: Enabling and configuring shared folders...
    default: -- /Volumes/hd1/Dropbox/work/hashicorp/windowsbuild: /vagrant
alvaros-Mac-mini:windowsbuild alvarom$ 

It works.


The only outstanding thing I found is the RDP is not enabled.


So, depending on your need, you may want to enable that or not.

I found the easiest way is to enable it like this with a ps1 shell:


What I did change?

Unattended file

   152                     <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="2048"}</CommandLine>    

configure-winrm.ps1

   4 winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'

    19 Set-Item wsman:localhost\Shell\MaxMemoryPerShellMB 2048 -Force


attached the updated version 


So, if this should have failed, what I would try will be let packer to upload it, for this packer have these parameters:

tools_upload_flavor (string) - The flavor of the VMware Tools ISO to upload into the VM. Valid values are "darwin", "linux", and "windows". By default, this is empty, which means VMware tools won't be uploaded.

tools_upload_path (string) - The path in the VM to upload the VMware tools. This only takes effect if tools_upload_flavor is non-empty. This is a configuration template that has a single valid variable: Flavor, which will be the value of tools_upload_flavor. By default the upload path is set to {{.Flavor}}.iso.

This will give you an iso... so you would need 7zip to uncompress the iso..

Install 7zip:
https://gist.github.com/sneal/73a0a088c55fbbe07ec6

Install VMtools:
https://github.com/joefitzgerald/packer-windows/blob/master/scripts/vm-guest-tools.bat#L13-L27

This last script, will reuse the windows.iso in /c/users/vagrant or download from internet

won't be cheating.. will be using the less resistance path.

That the machine will be used by winrm, doesn't require everything should be done by winrm.. the upload was sloooooooow

Enjoy


Alvaro.
windowsbuild.zip

Lucius Bono

unread,
Jul 19, 2015, 2:02:01 AM7/19/15
to packe...@googlegroups.com
WOOHOO! Alvaro you're a genius. I'm finally able to build my box with the changes you suggested. Uploading the VMWare tools ISO via the tools_upload_flavor and tools_upload_path weren't working for me before, but I bet that had more to do with the PS session attributes and the VM's attributes. I've now got a pretty solid build, and the good news about all these issues is I was able to "prune out" a lot of settings that were redundant. 

Now that it works, I'll start tuning things. I'd like to get this box working with as few scripts and commands as possible. 

Still odd that the file provisioner wasn't working. 

Lucius Bono

unread,
Jul 20, 2015, 11:56:42 AM7/20/15
to packe...@googlegroups.com
Just wanted to share with everyone how my project is coming along. I made some really solid progress over the weekend and I now have a working build:


I still have some kinks to work out, but I feel a lot more confident that I can get tit done. Big thanks to everyone who pitched in and helped me get on my feet!

Alvaro Miranda Aguilera

unread,
Jul 20, 2015, 5:35:00 PM7/20/15
to packe...@googlegroups.com
Hello Lucius

Just a note.

You can cut your project in 2, say on build to create basic boxes using vmware-iso

once that box is done, you can keep the folder where the box is built, that will have a vmx file and the vmdk disk

then you can reuse that folder and use vmware-vmx to spin the new box

I do this all the time, and the workflow is something like this:

multi_state


If you want to give a try, check this example (this have vmware-iso + vmware-vmx):

here is the idea explained:

Alvaro



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Lucius Bono

unread,
Jul 20, 2015, 7:29:40 PM7/20/15
to packe...@googlegroups.com
Intersting - so you're saying you create a single vanilla base image, and then use Make to clone that box and then layer packages / configuration on top? This might be a little over my head, but it looks like a great project!

Alvaro Miranda Aguilera

unread,
Jul 20, 2015, 9:02:51 PM7/20/15
to packe...@googlegroups.com
easier than that

packer vmware-iso provider

- take an iso and create  base-box

inside this base box you end with

base-box/file.vmx
base-box/file.vmdk

one is the vm definition |small), other the vm disk (just what you use.. say 1gig)

then you use vmware-vmx provider, that will copy those files and create a new VM using a copy of that VM disk

so in your case, say your base install take 1 hour

then the 2nd/3er/4th VM will take just the delta

:)





Lucius Bono

unread,
Jul 29, 2015, 9:20:43 PM7/29/15
to Packer, kik...@gmail.com
Wanted to pop in here really quick and thank everyone again. My project is coming along nicely. I now have a full Windows Update check working (through WinRM, not SSH): https://github.com/luciusbono/Packer-Windows81

That project assumes you've downloaded the ISO locally. I'll eventually have this up in Atlas! Really pleased with my progress and I really owe it all to this thread. 
Reply all
Reply to author
Forward
0 new messages