Saturday, 2 June 2012

Creating a VM template - Part 2

With the template created in vMware I opened the console and powered on.
From there it’s simply a case of following your standard Windows installation routine.
Once installed, I’m now in the guest OS and can start configuring that.
First I disconnected the CD drive from the ISO in vMware.
Then in disk management I brought the PageFile disk online, initialised it, and then created a new partition using the whole 8GB.
I assigned this drive the letter P, and labelled it PageFile.
Once that was complete, I went into system properties, disabled the PageFile on C:\, and set a static PageFile on P:\ of 3072MB (1.5*Physical Memory).
Then, instead of rebooting right away for this to take effect I wanted to run windows update. To kill two birds with one reboot so to speak.  This required entering some temporary settings on the network adaptor.  I haven’t enabled DNS on the Firewall appliance as I want to run DNS internally, so I’ve temporarily assigned one of the Google DNS servers. ( is so useful in these circumstances, not exactly easy to forget this IP address).
Windows update found 64 important and two optional updates. I selected to install them all.
Once the updates were installed I went ahead and performed the reboot. Once the system was back up I re-ran Windows update, which picked up a couple of additional updates which I also applied.

I then went back into the main v-Sphere client and selected the option to install vMware tools on the client. Back on the guest I ran the installer.

Going with the default settings, it is pretty much a next, next, finish process. I then set the properties of IPv4 back to automatically obtain settings (despite the fact this won’t work), and performed another reboot. I disabled indexing of file contents on C:\, and performed a defragmentation. This completed very quickly thanks to being homed on the SSD’s.

The free version of the v-sphere client, when connected directly to an ESXi server lacks the ability to create templates from VM’s, and to deploy from templates. You need to connect to a vCenter server to have this ability. (Supposedly you can also do this with the essentials kits, but I haven’t been able to independently verify this). vMware offer a free 60 day trial of vCenter server, and it is available as a virtual appliance. Hopefully 60 days should be enough for me to get the majority of VM’s for this lab spun up. I won’t go into details for the deployment process of the virtual appliance, there are a number of guides out there, aside from to say to avoid another 4GB upload from my home machine I I downloaded it to the temporary VM I created earlier in the lab, installed the v-Sphere client there too. This would also mean I could access the vCenter server without firewall changes to make it accessible from the internet. As a side note the vMware website is a nightmare to browse via a browser running on a guest being accessed by vSphere. Turning off image rendering helps a little but not much.

Once the vCenter server appliance was installed, it was a case of connecting the vSphere client, and adding the ESXi host to it. From there you can right-click the VM and choose convert to template. There is no need to run sysprep from within the guest operating system, for Windows 2008 machines vMware takes care of that. I initially added the physical ESXi host to vCenter using its public IP, but experienced a number of disconnects. Rather than troubleshooting the network connectivity through the firewall, I added a second management interface to the ESXi host on the internal 10.0.0.x network. This fixed the issue with the repeated disconnects. After this change I ended up with a network config in vMware as below.

In order to save disk space on the SSD’s, I also moved the template onto the SAS disk. This is accomplished by opening the Datastore browser, selecting the folder containing the template, choosing move and selecting the SAS Datastore as the destination. Once moved you need to go into the new folder, find the .vmtx file associated with the template, right clicking and choosing add to inventory.

As a final housekeeping task I removed the old template from the inventory. I’m now ready to begin deploying VM’s from this template.

No comments:

Post a Comment