On a recent VMware implementation, I was tasked with creating several virtual machine templates for an enterprise customer. During the initial phase of the implementation the customer would be running on a skeleton virtual infrastructure with just enough equipment to host the several virtual machines that they plan on deploying. There are several small changes that can be made to virtual machine templates that can help reduce overhead of the virtual machines you create within your virtual infrastructure to can help optimize CPU, Memory, and Disk usage.
The easiest way to conserve ESXi host resources is to right-size your virtual machines. When you use the Create New Virtual Machine wizard, VMware provides default recommendations for the number of CPUs and Memory for the Guest OS. As an example, VMware recommends 1 vCPU and 4096 MB of memory for a Windows Server 2012 (64-bit) Guest OS. Increasing these recommendations requires additional overhead to run the virtual machine, here is an example of the amount of overhead that is required. If the applications that you intend on running on your virtual machine don’t require additional CPU and Memory resources, stick with the defaults and monitor the performance of the virtual machine.
|Memory (MB)||1 vCPU||2 vCPUs||4 vCPUs||8 vCPUs|
Next disable unncessary hardware such as the Serial Ports, Parallel Port, and the Floppy disk controller. See VMware Knowledge Base Article Disabling COM and LPT from the Virtual Machine BIOS (1737)
Disk alignment is often overlooked when virtual machines are created even though just about every storage vendor has published a whitepaper on the topic. Cormac Hogan consolidated several of the vendor documents in the bottom of his VMware bLOG article Guest OS Partition Alignment. IBM was one of the first vendors to post information on the topic in their Technical report: Storage Block Alignment with VMware Virtual Infrastructure and IBM System Storage N series. Alignment is typically done prior to installing the operating system by attaching a .VMDK file to a virtual machine you have already created and using the diskpart utility. However 3rd party vendors such as EMC, DELL/Quest, and NetApp provide post installation alignment tools that can be used with your existing virtual machines. See Nicholas Weaver’s UBERAlign, DELL/Quest’s vOptimizer Pro, or NetApp’s mbralign.
Once the disk has been aligned, install the Operating System and VMware Tools.
After installing the OS and VMware Tools begin customizing the Guest Operating System. VMware’s Matthew Honigford created the presentation “Golden Master” Best Practices with View back in 2009 and I have found it to be one of the most comprehensive documents on Windows OS Optimization recommendations.
If you don’t have time to apply all of the recommendations above, at least consider disabling screen savers which can turn idle virtual machines into heavy CPU consumers. Don’t forget the logon screen saver 😉 See Disabling the Windows Logon Screen Saver (9275881)
Remember that making these changes when creating your Templates will ensure that all future virtual machines created from the Template are optimized. There are several tools available today that can help you automate these changes. Take a look at the VDI Optimizer .vbs script created by Richard Smith here Optimising Windows 7 Images for use in VDI and the The FREE Quest vWorkspace Desktop Optimizer