How To Build An Effective Virtual Machine Template
Page 3 of 3
Install the Operating System
When the VMware BIOS screen flashes, hit ‘F2’ to enter Setup.
Enter the “Boot” menu page and then use the “+” and “-“ keys to re-order your boot priority to the following:
Hard Drive
CD-ROM Drive
Removable Devices
Network boot from AMD Am79C970A
Press F10 to Save and Exit
When the VMware BIOS screen flashes once again press “ESCAPE” in order to display a Boot Menu.
Choose the ‘CD-ROM Drive’.
When prompted, hit ‘F6’ so that you can add a 3rd Party SCSI Driver.
You will be prompted to hit ‘S’ so that you can add a 3rd Party SCSI Driver.
Remember the FLP floppy image? This is why you went and got it earlier…the VMware SCSI Controller Driver!
That is the only SCSI driver you need.
Clicking ‘Enter’ will prompt you to continue.
Press C to create a NTFS partition using all available space. Follow on-screen instructions to begin installation.
During the installation of Windows, you may or may not see this screen. Remember the VMware SCSI Driver?
That is what it recognizes.
Works fine, so you can say yes.
Here it states that the VMware SCSI Controller is not ‘digitally signed…’
Yes you DO want to use this driver.
One more time with ‘consistency’.
Make the computer name…
‘winxpprosp2’.
Now the hostname, config file, NVRAM file, Virtual Disk File, ALL have the same name. Now if there is a problem with this host, VERY easy to find all the files that relate to this Virtual Machine.
Now finish up the operating system installation. Once logged in, there are a few things left to do to get your template ready.
Install VMware Tools.
On the toolbar, under the VM pull down list is ‘Install VMware Tools’.
Choosing this presents the correct ISO file to the Virtual Machine, and autoplay (if enabled in the Virtual Machine’s operating system) initiates the installation.
Go into the Control Panel.
Under User Accounts, click ‘Change The Way Users Log On Or Off’
Disable ‘Use Fast User Switching’ and ‘Use Welcome Screen’
Go into the Control Panel.
Under ‘Add/Remove Programs’, make any changes you need to remove unnecessary software (less is more when building a template).
Open Windows Explorer
Change the ‘View’ menu to suite your needs
Under Tools, Options, make any changes to the General and View tabs, and then verify that Offline Files are disabled.
Perform any necessary patching/updating to the operating system (Windows Update or Microsoft Update works fine for Windows XP).
Get the Microsoft Sysprep utility from the Microsoft website, or from the Windows XP CD-ROM. I got mine from the XP CD-ROM.
From the Virtual Machine’s point of view, attach the Windows XP CD-ROM, and find the following file,
D:\Support\Tools\Deploy.cab
When you double click this file, it opens up like a folder. Copy all these files, and make the necessary directory, to:
C:\sysprep
Another thing to do is create a file called ‘C:\sysprep\sysprep.inf’
This file will have some things to help you when you deploy your template, as far as making the process easier, and faster.
Replace the ‘xxxxx-xxxxx-xxxxx-xxxx’ with your license key so you don’t have to enter it EVERY time you boot the ‘template’.
Once updating, patching, and other base requirements are completed, let’s clean up the template. (Remember… the less you put into the initial template, the cleaner your base template is. You can always make more ‘templates’ from this later on).
Run ‘Microsoft Disk Cleanup’, and choose every option, EXCEPT for compression of older files. Get rid of all your Internet cookies, cache, and history. You don’t need it.
NOTE: I also put a file on my desktop called ‘My Customization.reg’. This is my registry hack, which I like to put on some of my machines. I did not import the file, just put it on the desktop, so as I deploy Virtual Machines from this template, I have the hacks readily available. You can do the same with any “common” setup file, config file, etc to make your deployment quicker.
Now for some steps specific to VMware.
Open VMware Tools (from either the Control Panel, or double-clicking the icon in your system tray). Go to the ‘Shrink’ tab.
Click ‘Prepare to Shrink’. (This may take up to 5 minutes to complete).
When asked if you want to ‘Shrink your disks now?’, click ‘Yes’.
The ACTUAL shrinking process may take up to 10-20 minutes. This made your VMDK file about 600 MB smaller in size.
This completes the cleanup of the Virtual Machine, and you’re ready to make a template out of this Virtual Machine.
Now for some steps specific to Microsoft.
Run
C:\sysprep\sysprep.exe
This starts the Sysprep process (which remove unique information such as hostname, TCP/IP address, SID, etc).
This means you will run a ‘Mini-Setup’ next time you power on this Virtual Machine, or a copy of it.
Click ‘OK’ to continue
Place a check in ‘Mini-Setup’.
Click ‘Reseal’ to finish creating the template. The Virtual Machine will power down when it completes the operation.
Once the Virtual Machine finishes powering off, you can clean up a couple of things to make life easier when you use the template.
Remove the Virtual Machine’s Floppy Drive (who uses floppies except for SCSI drivers anymore?).
Change the CD-ROM settings. Set it back to the Physical CD-ROM, and make sure the checkbox for ‘Connected At Power On’ is clear (not everyone will have the ISO file we used, and rather than get a warning when you power up the Virtual Machine….)
I added some notes regarding the build of this Virtual machine.
Close VMware Workstation (so that no files are locked for the next steps).
NOTE: Let’s look at the files that are in the directory for our Virtual Machine. Lots of stuff…
You can get rid of (delete) the LOG, NVRAM, and VMSD files (they’ll get recreated next time you power on the Virtual Machine).
Back up the Virtual Machine (I used Winzip, as shown here).
NOTE: I ‘zipped’ the directory, which made up the Virtual Machine. This way, when I extract the files, a directory will be created, and contain the VMX and VMDK files.
I got good compression by changing the default settings in Winzip.
The file ‘winxpprosp2.zip’ is now a backup of the template Virtual Machine.
When you deploy from this zip file, a couple of changes SHOULD be made.
Let’s assume we’ll be building a host named ‘web01’.
Edit the VMX file replacing ‘winxpprosp2’ three times in the VMX file.
IMPORTANT: (Do NOT change the 4th line down,
guestOS = ‘winxppro’
as that would break the Virtual Machine). Close and save the changes to the VMX file.
Change the name of the folder, VMX file, and VMDK file so they are all called ‘web01’.
Again, all the files and directories now are called ‘web01’, and you can easily find and identify the files that make up your Virtual machine.
The only thing left to do to keep the consistency in naming, is when you fire up the Virtual Machine, make sure you make the Computer Name ‘web01’.
Your Virtual Machine should be up and running now in about 5-10 minutes.
That’s worth all the effort we just gave.
###
Mark Gabryjelski is a Senior Engineer at Expert Server Group specializing in virtualization technologies. Mark holds certifications from Microsoft, HP, Novell, Sun and VMware.
Expert Server Group is one of the most experienced providers of enterprise-level virtual server and storage solutions in the Northeast. ESG works with clients of all size, including many Fortune 500 companies, to implement virtual technologies for Server Consolidation, Infrastructure Simplification, and Disaster Recovery and more. ESG is a founding member of VMware's elite VAC partner program and one of the few VMware Premier Enterprise Partners in the world.
www.expertserver.com