Kit Wai Chan - Fotolia


Create VM templates without encountering errors

Creating a VM template is a fairly straightforward process. Even so, it's a good idea to familiarize yourself with Microsoft's documentation to avoid common mistakes.

VM templates enable you to automate the VM creation process, which helps reduce the administrative workload. These templates are easy to create, but there are a few common mistakes to avoid.

The first thing to know about creating VM templates is that the template must be based on an existing object. This can be an existing template, a virtual hard disk from within the library or an existing VM. If you opt to create a VM template from a VM, that VM will be destroyed in the process. Therefore, you should create a clone of the VM prior to creating the template.

Even if you create the VM solely for the purpose of generating a template, it's still a good idea to clone the VM prior to building the template. You could spend hours creating a VM only to have the template creation fail and to have to start from scratch.

One of the more common reasons for a template creation failure is trying to create a template from a Linux VM. The template creation process attempts to Sysprep the VM, which doesn't work on Linux VMs because Sysprep is designed for Windows. The Sysprep process generalizes the Windows OS by removing any machine-specific data, such as the computer name or IP address.

If you need to create a System Center Virtual Machine Manager (SCVMM) template from a Linux VM, you must install the SCVMM agent on the VM, clear the network rules and then shut down the VM. From there, you can copy the VM's hard disk to the SCVMM library and use it as a source for the new template.

Domain-joined VM

Another best practice when creating VM templates is to make sure the model VM isn't domain-joined. Joining a VM to an Active Directory (AD) domain can cause the system to create a computer account for the VM within the AD database. Once Sysprep is running on the VM during the template creation process, this computer account is orphaned.

Rather than joining a VM to an AD domain and then creating a template, you should allow the template itself to handle the domain join. The Domain/Workgroup section of the Create VM Template Wizard's Configure Operating System screen enables you to specify that VMs spawned from the template should be domain-joined. This same screen also enables you to provide the required credentials.

Create VM template wizard
Figure A. Domain join operations can be controlled in the template.

When you create a VM template, it's important to secure the library share in a way that prevents anyone other than VM admins from gaining access; the template could contain sensitive information, such as a local administrator password or even domain-level credentials that can be used to join AD.

Preinstalled applications

Another thing to keep in mind as you create VM templates is that they are designed to help you automate the deployment of new VMs by running a specific OS that is preconfigured to meet your organization's needs. VM templates aren't designed to include preinstalled applications.

It's sometimes possible to include an application in a VM template, but the Sysprep process often breaks applications installed in the model VM.

If you want to use templates to automate the creation of application servers, you can use an application profile. Application profiles are somewhat limited in that you can only use them to script applications, SQL Server data tier applications or web applications, but many organizations point application profiles to an application deployment server.

As an alternative, you can also configure a VM template to run a script the first time someone logs into a VM created from the template. You can use such a script to perform an automated application installation.

Dig Deeper on IT systems management and monitoring

Software Quality
App Architecture
Cloud Computing
Data Center