SCVMM 2008’s Virtual Machine Templates

Creating templates lets you quickly and consistently provision VMs

Sean Deuby

February 16, 2009

12 Min Read
ITPro Today logo in a gray background | ITPro Today


Microsoft System Center Virtual Machine Manager (SCVMM) 2008 provides welcome updates to the original product. I gave an overview of SCVMM 2008 in "Let SCVMM 2008 Manage It All"; in this article I show you how to install the product and bring a Hyper-V host under its control. After I show you how to create a managed host, I explain how to clone an existing virtual machine (VM) and create hardware and OS profiles. Finally, I show you how to use these profiles and an existing VM to create a template that you can use to quickly generate a new VM to your specifications. (For information about SCVMM integration with VMware's ESX Server, see the sidebar "SCVMM and ESX Server Integration."

Installing SCVMM

You can download a 180-day evaluation version of SCVMM 2008 from the Microsoft TechNet website. Although you can install SCVMM in complex configurations that require multiple servers (as I discuss in "Let SCVMM 2008 Manage It All," for the purposes of this article we'll run all of the components (server, console, library, and Microsoft SQL Server database) on one server.

SCVMM 2008 has the following software requirements for successful installation:

  • The Server service must run on Windows Server 2008 x64 (although you can run SCVMM itself on a VM).

  • Both the Server service and the administrator console require Windows PowerShell, which is included in Server 2008.

  • SCVMM requires Windows Remote Management (WinRM), which is included in Server 2008.

  • You must configure Microsoft Internet Information Services (IIS) 7.0 (which Server 2008 includes) to run the IIS 6.0 Metabase Compatibility, IIS 6.0 Windows Management Instrumentation (WMI) Compatibility, Static Content, Default Document, Directory Browsing, HTTP Errors, ASP.NET, .NET Extensibility, ISAPI Extensions, ISAPI Filters, and Request Filtering features.

  • SCVMM requires SQL Server 2008, SQL Server 2005, or SQL Server 2005 Express Edition (which is included in SCVMM).

Most server-side components are included with either SCVMM or Server 2008 and are automatically configured when you install SCVMM. For more detailed information about the software and hardware requirements necessary to install SCVMM, go to the Microsoft System Center Virtual Machine Manager website.

Adding a Host to Manage

For the purposes of this article, I installed SCVMM on a Hyper-V host computer named THINKPADT61P, as Figure 1 shows, with SCVMM managing the host. Once the console is up and running, we need to add another host to manage. Selecting the Hosts view in the left-hand pane displays an Add host task in the Actions pane. Selecting the Add host task starts the Add Hosts wizard, which lets you easily find a host either by directly entering the host name or by using the wizard to search in Active Directory. For this article, I've already added the Hyper-V host HANSHI to be managed by SCVMM. Both hosts have their own Virtual Machine Manager (VMM) libraries, kept in sync through DFS Replication (DFSR). (You can install DFSR as a File Service role feature in Server 2008; for information about using DFSR, see "Get in Sync with DFSR."

Cloning the Template Source Virtual Machine

To create a VM template, you must first have a deployed VM to use as its source. For this article, I used a 64-bit Windows Server 2003 VM named W2K3R2x64. Because creating the template will destroy the VM, we must create a clone of the VM to use for the template. To create a clone, first make sure the VM is in either a stopped or saved state. Then, click the VM to highlight it, and select Clone from either the context menu or the Actions pane. The wizard will ask for the clone's name, hardware and network configuration, destination host, path on the host, and startup and shutdown properties. The wizard will also ask whether you want the cloned VM to reside as a deployed VM on a host or to be stored in the VMM library. If you store the cloned VM in a library, it is inactive and offline. To make the VM active, simply select the Deploy action. For this article, I left the original name, and I stored the cloned VM in HANSHI's library. Because the original VM will be destroyed to create the template, no duplicate names will exist.

Creating a Hardware Profile

The next step in building your VM library is to create a hardware profile. A hardware profile specifies the hardware configuration to be applied to a new VM created by SCVMM 2008. As Figure 2 shows, you can specify the number of processors and one of 25 different virtualized processor configurations, the amount of memory, the network to use, IDE/SCSI configuration, and more. By default, a hardware profile includes a built-in IDE drive (although you can't modify this drive until you create a VM). You can add and configure as many as four virtual SCSI adapters when you create a VM.

The benefit of using hardware profiles is that you can standardize the hardware across all your VMs. You don't need to create a different hardware profile for each OS configuration—only in cases in which the hardware requirements are different. For example, a Windows 2003 domain controller hardware configuration might require 1.5GB of memory with one processor, whereas a SQL Server 2005/Server 2008 configuration might require 4GB of memory with dual processors. For this article we'll create just one simple configuration that's sufficient for demonstrating the template process.

To create a new hardware profile, click the Library view in the left-hand pane of the SCVMM administrator console. Doing so will reveal the Library Actions section in the right-hand Actions pane. In the Library Actions section, click New hardware profile to launch the New Hardware Profile dialog box. Enter a short descriptive name, such as Default or Standard, as well as an optional description. Click the Hardware Settings tab to configure the hardware settings. Because we're creating a simple test configuration, 1GB of memory and any processor configuration is adequate.

Creating a Guest OS Profile

Now that we've created the new VM's hardware configuration, we need to also configure the OS. To do so, we'll use a guest OS profile. The guest OS profile is a customized version of the base OS configuration for the new VM it's applied against. You can think of the guest OS profile as a user-friendly version of Sysprep. You need to create a profile for each type of OS configuration; as with the hardware profile, having separate OS profiles lets you create a standardized set of OS configurations that simplifies the task of managing your virtual infrastructure.

To create a new OS profile, click the Library view in the left-hand pane. Click the New guest OS profile action to launch the Guest OS Properties dialog box. On the General tab, enter a short descriptive name, such as W2K3 R2 x64, to describe which OS the profile is designed for. Next, click the Guest OS tab to configure the OS profile. You can preconfigure a computer name, or you can let SCVMM randomly create an initial name. Enter the required name, organization name, and local administrator password. Enter a product key, unless the OS is a Server 2008 or Windows Vista volume license build, in which case you can leave this field blank. Note that the product key isn't obscured after you enter it, so anyone with rights to access the guest OS profile can also obtain the product key. The product key is obscured, however, when it's used as part of a VM template—so self-service users can't see it. Select the time zone and OS type. You can configure the profile to automatically join a domain or remain in a workgroup. Finally, if you want to execute additional commands, the dialog box provides options for an answer file, as Figure 3 shows, and for run-once command scripts.

Choosing a Virtual Hard Disk

The default SCVMM library has several dynamically expanding disks, which is adequate for our lab-based example in which space is more important than performance. In a production environment, you'd want to create several Virtual Hard Disks (VHDs) for your library that use fixed-size disks of different capacities. Fixed disks perform better than dynamically expanding disks, but because their size is fixed regardless of how much data is on them, they have a bigger effect on your storage requirements. Another caveat when using dynamically expanding disks is that host disk fragmentation can have a huge performance effect. Unlike a fixed disk, which is allocated as a sparse file when it's created, a dynamically expanding disk might use sectors scattered all over a fragmented disk.

Creating a New Template

Now that we have a VM to use as a baseline, as well as hardware and guest OS profiles to configure new machines, we need to create an SCVMM template to quickly generate new VMs. Like hardware profiles and guest OS profiles, a template is a database object; you won't find it in the SCVMM library folder structure. An SCVMM template combines a hardware profile, a VHD, and a guest OS profile. You can use a VHD either from the library or from an existing VM, but be aware that if you use an existing VM's VHD, the VM will be destroyed because the resulting Sysprep process strips the VM of its computer identity. Also, be sure the VM is free of restrictive password policies that could prevent Sysprep from setting the Administrator password. It's best to have the VM be a member of a workgroup rather than a domain so that the VM doesn't inherit the domain's security policies; appropriate policies will be enforced when a new VM is created from this template and joined to a domain.

To create the VM template, click New Template in the Library view to launch the New Template wizard. Select the source as an existing VM, and choose W2K3R2x64. (Alternatively, you can select the W2K3R2x64 VM, then click New Template in the Actions pane.) Click Yes to acknowledge that you plan to overwrite W2K3R2x64. Keep the same name, but consider adding a description of the hardware and guest OS profiles you'll use. Choose the default hardware profile in the Configure Hardware step and the W2K3 R2 x64 guest OS profile in the Guest Operating System step. (These are the profiles we just created.) For our example we'll create the template in THINKPADT61P's library.

The final step, Select Path, is a bit confusing. You might wonder why, if a VM template is a database object, this step asks for a share location in the library. This location is where the VHD that you associate with the template will be stored. To minimize confusion, I recommend that you create a subfolder in the VHD folder, called Template VHDs. This way, when you view the library via the file system you can easily see these VHDs' purpose. Confirm your settings, and click OK to begin the template creation. Figure 4 shows how the VM is stepped through the Sysprep process during template creation.

Creating a New VM

Now that we have a template, we can use it to create a new Windows 2003 R2 x64 VM. With the W2K3R2x64 template highlighted, click New Virtual Machine in the Actions pane to launch the New Virtual Machine wizard. (Alternatively, you can right-click the stored W2K3R2x64 template in the Library view and select New Virtual Machine.) For this article, I used W2K3R2x64-1 as the new VM's identity. As you progress through the wizard, you can make different hardware choices and choose a different guest OS profile—but if you just click Next, the wizard will use the values from the hardware and software profiles you incorporated into the template. Select the host on which you'll deploy the new VM (I deployed the VM to HANSHI) and select the path on the host where the VM will be stored. If you previously configured the default VM path, you can just click Next. Select the network interface on the host you want to use, and indicate what actions the VM should take when the host server starts and stops. In the Summary screen you can choose to automatically start the VM after it's been deployed to the host server. Click Finish to start the VM creation.

Additional Tips

If you encounter a problem working with a VM in SCVMM that requires repair outside of SCVMM (e.g., in Hyper-V), right-click the VM, select Repair, then select the Ignore radio button to dismiss the failed state and simply refresh the VM's status within SCVMM. Hyper-V networking can be confusing. SCVMM has a "view networking" feature that shows you a graphical representation of how a VM is connected to the host and network. You can even broaden the scope to show the network configuration of all the VMs on the host. Using this feature is helpful for ensuring that you configured networking correctly in case you have connectivity problems.

SCVMM Best Practices

SCVMM's VM template feature lets you quickly and consistently provision VMs. Although you might be tempted to start creating VMs within minutes of installing SCVMM, I recommend that you take the time to understand VM templates first. Then, gather your requirements for both VM hardware configurations and OS profile types. Use these requirements to create appropriate hardware profiles and guest OS profiles. Copy your stable of ISO disk images to the VMM library, and consider using a feature such as DFSR to keep all your libraries in sync with one another.

Once you have all the building blocks in place, create and configure template VMs of each OS type, and perhaps even for configurations within types. Clone them for safekeeping into the VMM library, then create VM templates from these template VMs. With the resulting library of preconfigured templates, you can quickly provision VMs when the need arises. Just don't forget to manage these VMs through their complete life cycle, which includes storing them back in the VMM library or decommissioning them when they're no longer needed.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like