Monday, April 8, 2013

Building a VMware Virtual Machine Template - Walkthrough Guide

**** Updated 06-12-2013 **** Spelling corrections, updates to notes and included OS video card update information.

There are quite a few posts already on building a VM template but I found that I was having to reference a several blog posts in order to get the complete picture. So I'm finally getting around to writing my own for future reference.

I'll list some great links to other VM Template guides at the end of the post.

  • Create a new VM with the required specifications.
    • Disk
    • CPU - Make the default use CPUs not Cores
    • RAM
    • NIC - VMXNET3
    • SCSI0 - LSI Logic SAS for Windows 2008
    • Floppy - Remove
    • OS - Make sure to select the correct OS
  • Build a standard for the template name to cover different OS versions and editions for example;
    • W2K8R2SP1ENTx64 - Windows 2008 R2 Service Pack 1 Enterprise 64bit
    • W2K3SP2STDx32 - Windows 2003 Service Pack 2 Standard 32bit
    • RHEL61x64 - Red Hat Enterprise Linux 6.1 64bit
  • Install the OS inside the VM (typically from CD ISO)
    • Choose a default Administrator username and password
    • Set time zone
    • Set regional options
    • Set language packs
    • Set keyboard layout
  • Upgrade VM hardware version to the latest level available
  • Modify VM settings
    • Disable VM Logging
    • Set CD/DVD to 'Client Device'
    • NIC - Select default build VLAN/Portgroup
    • Video Memory - For one monitor @ 1024x768 use 3MB
    • Set description of the template within the Notes section
  • BIOS Settings
    • Disable serial ports
    • Disable parallel ports
    • Set HDD as primary boot device
    • Disable floppy disk drives
  • Install VMware Tools - Choose custom install
    • Unselect vShield Drivers
    • Unselect Shared Folders
    • Unselect Virtual Printing
    • Unselect Wise Multimedia Support
  • Update video card driver to WDDM driver (‎)
  • Anti-Virus client install - Agentless is preferred if that is available
  • Backup client install - Agentless is preferred if that is available
  • Set VM name within the OS to match the template name
  • Activate OS - Microsoft KMS if available
  • Enable Remote Desktop
  • Create folders on C:\ partition
    • C:\Temp
    • C:\Scripts
    • C:\Source
    • C:\Tools
    • C:\BGInfo
  • Configure BGInfo application
    • Create a shortcut with the following syntax; C:\BGInfo\Bginfo.exe "C:\BGInfo\BGinfo_Win2K8.bgi" /SILENT /TIMER:0 /NOLICPROMPT
    • For Windows 2008 put the shortcut in: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
    • For Windows 2003 put the shortcut in: C:\Documents and Settings\All Users\Start Menu\Programs\Startup
  • Install Windows Updates
  • Install Windows Features but do not install the following options by default;
    • Microsoft .Net Framework
    • Silverlight
    • IE Compatibility
    • Best Practices Analyzer
  • Set Power Plan to High Performance
  • Set Turn off the display to Never
  • Set Put the computer to sleep to Never
  • Firewall - Set on or off depending on your organization policies and practices
  • Disable UAC
  • Set screen resolution to 1024x768
  • Purge Temporary Folders;
    • C:\Windows\Temp
    • C:\Windows\$directory$
    • C:\Users\Administrator\AppData\Local\Temp
  • Release IP address of server (Set to DHCP)
  • Shutdown VM
  • Convert VM to template
The CD-ROM drive will be set as D: drive by default. I always change this to Z: drive, but this cannot be part of the template. There are smarter ways to do this, like scripts that run post deployment.

Once every couple of months we need to convert this template back to a VM, power it on and then patch it up to the latest version. Then redo the steps from Purging Temporary Folders onwards.

Comprehensive guide and walk through on building VM Templates;
Comprehensive guide and walk through on building VM Templates;
List of Sysprep files required for various operating system customization's;

Tuesday, February 19, 2013

ESXi Custom Image Build Walkthrough

The following post is a detailed walkthrough on the process of creating a customized ESXi image. This would be used when building a vSphere environment with servers that must have components upgraded for functionality or support.

For this walkthrough I will be using Cisco UCS blade and rack servers. Also in use is Cisco VM-FEX technology which leverages the Nexus 1000v Virtual Ethernet Module (VEM) so this component will need to be installed along with the drivers for Cisco's VIC1280 Converged Network Adapter (CNA).

You may wonder why it is that I'm using a customised image based off VMwares standard ESXi source instead of the Vendor supplied ESXi image. The answer is quite simple; on every project I've ever worked on the Vendor supplied installation media is always several versions behind. At the time of writing this post Cisco only has a Cisco branded ESXi image up to version 5.0 and what I need right now is 5.1. In my experience it is always better to take the VMware branded image and add the components required.

The first step is to download the ESXi ZIP bundle and the driver bundles for the Nexus 1000v and the CNA card, and then store them in a temporary location. Specifically the files I'm working with for this post are;

Now we need to pull the offline bundles out of the driver packages. We are looking for a zip file inside the zip file with the following folders/files in the root;
  • vib20
  • index.xml
  • vendor-index.xml
Once we find the files, copy them to the temporary location. They must stay as ZIP files so that the PowerCLI cmdlets can interact with them. In this situation the offline bundles are;

Now it is time to launch PowerCLI and create the image. It is important to note that all data within this session will disappear once the PowerCLI window is closed. Before closing this window at the end of the walkthrough make sure to save both the ISO and ZIP files for easy re-import next time walking through this process.

Add the ESXi image and driver bundles to the Software Depot repository.
  • Add-EsxSoftwareDepot E:\Temp\
  • Add-EsxSoftwareDepot E:\Temp\
  • Add-EsxSoftwareDepot E:\Temp\
  • Add-EsxSoftwareDepot E:\Temp\

List all current ESXi image profiles, make a new image profile by copying the existing standard image and then list the components that are going to be added. The asterisk (*) can be used as a wildcard in PowerCLI.
  • Get-EsxImageProfile | FT Name, Vendor
  • New-EsxImageProfile -CloneProfile ESXi-5.1.0-20121004001-s* -Name ESXi-5.1.0-b838463 -Vendor VRIF
  • Get-EsxSoftwarePackage -Vendor Cisco

Add each of the required packages to the newly created image.
  • Add-EsxSoftwarePackage -ImageProfile ESXi-5.1.0-b838463 cisco-vem-v150-esx
  • Add-EsxSoftwarePackage -ImageProfile ESXi-5.1.0-b838463 net-enic
  • Add-EsxSoftwarePackage -ImageProfile ESXi-5.1.0-b838463 scsi-fnic

Compare the source profile to the newly created profile and confirm that the extra components have been added.
  • Compare-EsxImageProfile -ComparisonProfile ESXi-5.1.0-b8* -Reference ESXi-5.1.0-20121004001-s*

Export the image to be used as an ISO and ZIP bundle. The ZIP bundle is required for easy re-import into a PowerCLI session.
  • Export-EsxImageProfile -ImageProfile ESXi-5.1.0-b8* -ExportToIso -FilePath E:\Temp\ESXi-5.1.0-b838463.iso
  • Export-EsxImageProfile -ImageProfile ESXi-5.1.0-b8* -ExportToBundle -FilePath E:\Temp\

Now the ISO file can be used as a normal ESXi build disc. Attach it to your host and build the OS.

The ZIP bundle can be used to re-import the Image back into PowerCLI for editing and updating.

This process is just one of many ways to get extra drivers installed into ESXi. The reason I like this method is that you only need to do it once and then roll out the image to the hosts.