chris - Fotolia
Hyper-V VM template creation made easy
Creating Hyper-V VM templates is a straightforward process, but there are a few things you should consider, such as template creation source and administrative password assignment.
Even though the actual process of creating a new Hyper-V VM template is simple, there are several best practices you must be aware of before you build your first template.
You can use a Hyper-V VM template to automate VM creation. To create and use templates, you must deploy System Center Virtual Machine Manager (SCVMM).
To create a template, just open the SCVMM console, go to the Library workspace and then click the Create VM Template icon found on the toolbar. Figure A below shows this icon, along with an existing template in the VM Templates container. At this point, you'll be taken to the VM Template Wizard, which you can see in Figure B below.
As you can see in Figure B above, the Hyper-V VM template creation process is relatively straightforward. The process begins by selecting either an existing VM template, a virtual hard disk within the library or a VM to act as the basis for the template. From there, you must give the template a name and then configure the virtual hardware settings and the operating settings the VM will use. You can see the hardware settings in Figure C below and the operating settings in Figure D below. Both of these screens are similar to those used when creating a new Hyper-V VM.
Hyper-V VM template creation best practices
By far, the most important thing you must know about the Hyper-V VM template creation process is that, if you choose to base the template on an existing VM, then the source VM will be destroyed by the template creation process. When you use a Windows VM as the source for a VM template, SCVMM will run Sysprep on the source VM. This randomizes the VM, stripping all VM-specific settings, such as the computer name, IP address, accounts and domain membership.
Not every VM is a good candidate for template creation. For example, SCVMM requires the VM's system partition to be the same as the Windows partition. If the two partitions are different, then the VM can't be used as a template creation source.
There is a way to base a template on an existing VM without destroying it. To do so, shut down the VM you want to use, and then copy its virtual hard disk to the SCVMM library. Remember, SCVMM enables you to base a template on a virtual hard disk within the library. By using this approach, you're essentially basing the template on a copy of the VM -- or a copy of its virtual hard disk -- rather than on the VM itself.
It's worth noting that basing the template creation on a virtual hard disk rather than on a VM doesn't negate the need to run Sysprep. You must Sysprep the virtual hard disk prior to creating a Hyper-V VM template. This removes any machine-specific settings and configuration items from the virtual hard disk, thereby making its configuration generic enough to be used in a template.
Regardless of whether you're creating a template from a VM or from a virtual hard disk, you must deal with the issue of assigning an administrative password to VMs that are spawned from the template. The OS settings screen in Figure D includes a field you can use to specify the password.
Although it isn't usually a problem to embed a password in a template, some administrators are understandably reluctant to do so. If you have qualms about including a password in a template, then use an asterisk instead. This causes SCVMM to prompt you for a password during the VM creation process. If you were to simply leave the password field blank, then the password creation process would fail.