Share via


Creating a Template and Successfully Deploying New VMs

Template documentTemplates save time! Templates make multiple custom deployments easy! Learn to use Templates!

So, essentially I have marked up two great TechNet articles on creating virtual machines from templates. This sounds a bit backwards, but these articles provide all the information needed to Create A Template. I have pointed out important points and added comments where a newbie may easily go astray. Consider this a ‘Best Practices’ for simply creating a usable template. As you learn to master this process you may find yourself branching out into greater and greater customizations. Note that there are TWO DOCUMENTS BELOW.

Having trouble reading the documents below? Links available for direct download: Doc1 Doc2

 

 




Annotated for Newbies! [Comments in RED are mine.] Items in BOLD ITALICS are emphasis I added. My comments are not corrections to the document, but instead should help you understand better how to create Templates.

 

Creating Virtual Machines from a Template

Updated: November 5, 2009

Applies To: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2

https://technet.microsoft.com/en-us/library/cc764306.aspx

A virtual machine template is a library resource that consists of a hardware profile, a virtual hard disk, and an optional guest operating system profile. Templates provide a standardized group of hardware and software settings that you can use to create multiple new virtual machines configured with those settings. VMM supports:

  • Customized templates. The most common VMM templates that require an operating system profile to automate deployment. [Make these.]
  • Non-customized templates. Non-customized templates do not have an operating system profile attached and can be used for operating systems that you cannot customize, such as Windows 7 or Linux. [Newbies should not make these.]

clip_image002Note

VMM 2008 R2 supports customization of Windows Server 2008 operating systems on virtual machines that are deployed on ESX Server hosts managed by VirtualCenter 2.5 Update 4.

A virtual machine template consists of the following parts: [These are the three items required. Remember them.]

  • Hardware profile. To define a standard set of hardware settings, you can create a hardware profile and associate it with a template. When you create a new template or create a virtual machine from a template, you can specify the virtual hardware settings or reuse an existing hardware profile from the library. Like operating system profiles, hardware profiles are logical entities that are stored in the database. For more information, see Working with Hardware Profiles (https://go.microsoft.com/fwlink/?LinkID=163333). [Hardware profiles allow you to set CPU, RAM, Networks and so on. A few example profiles you might create: one for machines that need a lot of hardware, one for machines that need little.]
  • Virtual hard disk. You can use a generalized virtual hard disk from the library or create a virtual hard disk from an existing virtual machine. [This simply means that you already ran Sysprep manually on a VM yourself, then saved the VHD file to the Library.] If the source virtual machine for your template has multiple virtual hard disks, select the disk that contains the operating system. To simplify the generalization process, include Virtualization Guest Services (such as Virtual Machine Additions or Integration Components) in your template. For more information, see How to Create a Template from a Virtual Hard Disk (https://go.microsoft.com/fwlink/?LinkID=162949)
  • Guest operating system profile (optional). To use the same product key, administrator password, time zone, and other items in a set of templates, you can create a guest operating system profile and store it in the library. When you create a new template or a virtual machine from a template, you can specify the settings manually or use an operating system profile associated with your answer files. For more information, see Working with Guest Operating Systems (https://go.microsoft.com/fwlink/?LinkID=163332). [Simply explained… Fill out these items correctly and you are saved the trouble of creating a customization file for Sysprep. The Guest profile feeds information to the new VM when it is first deployed so you don't have to enter any information manually. Everything becomes automatic!]

Creating a Template

The following table describes the different ways of creating templates.

Template Type

Description

Templates created from an existing virtual hard disk

[This is the hard way. You run Sysprep with no customizations then save the VHD to the Library. Use the third method below instead.]

To create a virtual machine template from an existing virtual hard disk, prepare the source virtual hard disk, which has the operating system installed, by removing computer identity information. With Windows operating systems, for example, you can prepare the virtual hard disk with the Sysprep tool. Add the source virtual hard disk file to the Library and complete the New Template Wizard. For more information see How to Create a Template from a Virtual Hard Disk (https://go.microsoft.com/fwlink/?LinkID=162949).

clip_image002Note

You can also create a template from an existing VHD that is not sysprepped by using a non-customized template.

Templates imported from VMware

After you add a VMware VirtualCenter server to VMM, use the Import templates action in Administration view to import your VMware templates to the Virtual Machine Manager library so that you can use the templates in VMM. For more information, see How to Import VMware Templates.

clip_image002Note

To successfully import a VMware template, the VMM library server must be able to resolve the ESX Server.

Templates created from an existing deployed virtual machine

[This is the method of choice. Create a VM the way you like it, then shut it down. Tell SCVMM to turn this VM into a Template so you can deploy copies of this VM.]

 

[NOTE:

Make a copy of the great VM before you have SCVMM turn it into a Template. Why? Just in case you want to make a change to it or otherwise and make another template. Making a copy of a VM is called CLONING. Right click the VM, Select 'Clone' and make a copy running on a Host, not stored in the Library.]

When you create a template from an existing virtual machine, consider the following:

· The virtual machine that you use as a source to create a template must be a virtual machine that is deployed on a host (not stored in the library).

· The source virtual machine becomes the new template and is therefore no longer available as a virtual machine after the New Template Wizard completes.

· If the source virtual machine contains checkpoints, you must:

1. Delete all checkpoints from the virtual machine in the VMM Administrator Console

2. Stop or do a Save State on the virtual machine

3. Open the Hyper-V Manager on the host and check the status of the merge operation for the virtual machine

4. After the merge process is complete, create the template within the VMM Administrator Console

clip_image004Caution

You cannot avoid destroying the virtual machine if you use the virtual machine to create a template. However, before you run the New Template Wizard, you can first create an identical copy of the source virtual machine by using the Clone virtual machine action in the Administrator Console in the Actions pane in Virtual Machines view.

For more information, see How to Create a Template from a Virtual Machine (https://go.microsoft.com/fwlink/?LinkID=162950).

Templates created for use by self-service users

[We will ignore this part of the article as we are not interested in this right now.]

When you create a self-service user role (to enable a user or group of users to create or manage their own virtual machines), you can optionally specify one or more templates to enable users to perform the following tasks:

· All self-service users can modify the computer name on the guest operating system profile on a template.

· Users to whom you grant appropriate privileges can also modify the Administrator password and Product Key number on the guest operating system profile on a template.

clip_image002Note

Self-service users cannot modify any settings on the hardware profile on a template.

For more information about self-service user roles, see About Virtual Machine Self-Service and Role-Based Security in VMM (https://go.microsoft.com/fwlink/?LinkId=119337).

Non-customized templates

[Do this on your own. I do not recommend this method.]

Non-customized templates do not have an operating system profile attached and can be used for operating systems that you cannot sysprep. For example, you can create a virtual machine for Linux from a template, but the customization must be done by the user. When creating a template from VHD or from an existing virtual machine, in the guest Operating System Profile selection page, choose Customization Not Required.

Creating a Virtual Machine from a Template [How to use the great Template you just created]

When you start the New Virtual Machine Wizard and select a template from the library, the virtual machine settings will be set to those specified in the template. You can override the settings if you choose. With a customized template, VMM will build the virtual machine per your virtual hardware profile and apply the sysprep settings. [These are the settings you entered in the OS Profile to automate VM deployment entirely.]

If you want to want to use scripting to build several virtual machines from a template and place them in the library, start by creating a maintenance host group with one or more hosts. Have your script scope placement to that host group and once customization completes, you can script the saving of the resulting virtual machine into your library.

Requirements

  • The virtual hard disk must have a supported operating system installed. For more information, see Supported Operating Systems for Virtual Machines.
  • The Administrator password on the virtual hard disk should be blank as part of the Sysprep process. [Sysprep during the Template creation process does this for you.]
  • For customized templates, the operating system on the virtual hard disk must have been prepared by removing computer identity information. With Windows operating systems, for example, you can prepare the virtual hard disk with the Sysprep tool. [If you created a Template from a VM as recommended earlier you can ignore this section.]

clip_image002Note

If you create a new virtual machine from a template, you cannot store the virtual machine in the library but must place it on a host. That is because the customization step cannot be completed offline.

For more information, see How to Create a Virtual Machine from a Template (https://go.microsoft.com/fwlink/?LinkId=163808).

 

 




 

 

Annotated for Newbies! [Comments in RED are mine.] Items in BOLD ITALICS are emphasis I added. My comments are not corrections to the document, but instead should help you understand better how to create Templates.

 

How to Create a Virtual Machine from a Template

Updated: August 14, 2009

Applies To: Virtual Machine Manager 2008, Virtual Machine Manager 2008 R2

https://technet.microsoft.com/en-us/library/cc917940.aspx

This topic describes how to create a virtual machine from a virtual machine template.

Considerations

  • You cannot change the system disk or startup disk configuration.
  • Templates are database objects that are displayed in Library view by clicking Library Servers in the navigation pane. Templates are displayed in the VMs and Templates folder.

Requirements

  • The virtual hard disk must have a supported operating system installed. For more information, see Supported Operating Systems for Virtual Machines.
  • The Administrator password on the virtual hard disk should be blank as part of the Sysprep process. However, the Administrator password for the guest operating system profile does not have to be blank.
  • For customized templates, the operating system on the virtual hard disk must have been prepared by removing computer identity information. For Windows operating systems, you can prepare the virtual hard disk by using the Sysprep tool.

clip_image002Note

Optionally, you can use a non-customized template without an operating system profile.

Procedure

To create a virtual machine from a template:

1. In the Virtual Machine Manager Administrator Console, in Virtual Machines view, click New virtual machine.

2. Complete the New Virtual Machine Wizard.

Wizard Page

Action

Virtual Machine Identity

Configure the following options:

· Virtual machine name (required). Type a unique name for the virtual machine.

· Owner (required). The owner must have a domain account in Active Directory.

· Description (optional). Type a description for the new virtual machine.

Configure Hardware

To configure additional hardware for the virtual machine, use the following procedures:

· Startup Order —Select the order of devices to start the operating system.

· CPU Requirements —Specify processor requirements for the virtual machine.

· Memory —Specify the amount of memory to allocate to the virtual machine

· Floppy Drive —Configure the virtual floppy drive to read a physical floppy disk on the host or to read a virtual floppy disk file stored in the library.

· DVD or CD Drive —Add a virtual DVD or CD drive to an IDE bus.

· Virtual Hard Disk —Add a virtual hard disk to an IDE device or a SCSI adapter.

· Network Adapters —Configure one or more virtual network adapters for a virtual machine.

· Priority and Availability —Configure the virtual machine's priority for CPU resources on the host. Configure the virtual machine to be highly available.

Guest Operating System

(for customizable templates only)

[Set the 'Operating System' first. Everything else will work a bit better this way.]

Configure identity information, administrative credentials, and user access to computers based on the template.

· General Settings: Enter the following settings:

· Identity Information: Specify a computer name. To generate a computer name randomly for virtual machines based on the template, enter an asterisk in the Computer name field.

· Admin Password: Specify the local administrator password for the virtual machine. If virtual machines created with this template will not be in a domain, users must use this password to gain access to the local computer.

clip_image002Note

To prompt for a password when the user creates a virtual machine with the template, enter an asterisk (*) in the Admin Password field. If you leave the field blank, virtual machine creation fails. [Don't want to be prompted for a password? Want the Template to be deployed successfully? Fill in a password here! Do not leave blank or use an '*' asterisk.]

· Product key: If you want the template to provide a product key for virtual machines, enter a product key in the Product key field. To require users to provide their own product key when they create a virtual machine, leave the field blank. [Windows Vista/Windows 2008 and up: Use this link to enter a Sysprep product key to allow the full deployment to be automated. Once the new VM is up and running you can enter your correct KMS or MAK key.

Configuring KMS Clients

https://technet.microsoft.com/en-us/library/ff793406.aspx]

· Time Zone: Select the appropriate option from the Time Zone list, or accept the default time zone.

· Operating System: Select the operating system that will run on the virtual machine. This selection does not install an operating system. [Set this first! Trust me!]

· Networking: Configure settings to determine network access for virtual machines:

· Domain/Workgroup: If you want virtual machines that are created from this template to be in a domain, click Domain. Then specify a user account that will be used to add the computer to the domain at first log on. If the virtual machines that are created from this template will not be in a domain, click Workgroup, and then enter the name of the workgroup. [New to Templates? Having difficulty? Choose Workgroup! See if this works. Joining a domain can sometimes be a tricky process. Make sure everything else is working first.]

· Scripts: Use the options under Scripts to provide additional settings for Sysprep: [If you are a Sysprep veteran and know all there is to know about Sysprep please read this section. Otherwise, skip this! Make no changes in the Template.]

· Answer File: You can attach a Sysprep file (for Windows XP, Windows Server 2000, or Windows Server 2003) or an Unattend.xml file (for Windows Vista or Windows Server 2008) to the guest operating system profile. The answer file script must be stored on a library share. To select an answer file, click Browse to open the Select sysprep.inf script dialog box, and then select the file. To add settings, in the Answer file field, specify the Sysprep or Unattend file to run. The settings in the answer file will be appended to those from the wizard.

· [GUIRunOnce] Commands: If you want to specify one or more commands to run the first time a user logs on to a virtual machine, type a command that you want to add in the Command to add field, and then click Add. This action adds the command to the [GuiRunOnce] section of the Sysprep file.

clip_image002Note

To enable environment variable expansion when you create a new virtual machine from a template, you must precede GuiRunOnce commands with cmd.exe /c.

Select Destination

When creating a virtual machine from a template, you must choose the Place the virtual machine on a host option.

Select Host

Review the rating for each host to determine the most suitable host on which to deploy this virtual machine.

clip_image003Note

If many hosts are listed, you can use the Host group, Look for, or Group by fields to display a smaller set of potential hosts.

All hosts that are available for placement are given a rating of 0-5 stars based on their suitability to host the virtual machine. The host ratings are based on the virtual machine's hardware and resource requirements and expected resource usage. They are also based on placement settings that you can customize for VMM or for individual virtual machine deployments. The ratings are recommendations. You can select any host that has the required disk space and memory available. For more information about how VMM rates hosts, see How Virtual Machine Manager Rates Hosts.

clip_image005Important

In VMM 2008 R2, for hosts that are running Windows Server 2008 R2 or for ESX Server hosts, the ratings that first appear on the Select Host wizard page are based on a preliminary evaluation by VMM. To see the host rating based on a more thorough evaluation, you must select the host by clicking it.

1. To see the placement settings that VMM used to rate the hosts, and optionally to change those settings, click Customize Ratings.

2. To view additional information about a host rating, select the host in the list, and then use the tabs in this section to view the following information:

· Details -- This tab displays the status of the host and lists the virtual machines that are currently deployed on it.

· Ratings Explanation -- If a host receives a zero rating, this tab lists the conditions that caused the rating.

· SAN Explanation -- If a SAN transfer cannot be used to move the virtual machine's files to the host, this tab lists the conditions that prevent a SAN transfer.

If a host has network optimization enabled, a green arrow appears in the Network Optimization column. VMM 2008 R2 lets you take advantage of network optimization capabilities that are available on Hyper-V hosts that are running Windows Server 2008 R2. For information about network optimization and the hardware that supports it, see the Windows Server 2008 R2 documentation. After a virtual machine is deployed, this feature is displayed only for virtual machines that are deployed on a host that is running Windows Server 2008 R2. If no host in the list has sufficient disk space to host the new virtual machine, click Previous to return to the Volume Configuration page and either remove or reduce the size of one or more volumes. You can also override the default placement options that VMM uses to calculate the host ratings. Any changes that you make apply only for this virtual machine deployment. For more information about how VMM rates hosts, see How Virtual Machine Manager Rates Hosts.

Select Path

Accept the default virtual machine path on the host to store the files associated with this virtual machine. You can also click the down arrow to select a different path, or click Browse to specify a different path on the host. You can also choose the following options:

· If you selected a path other than an existing default path and want to store other virtual machines on that path, select the Add this path to the list of host default paths check box. For information about how to configure default virtual machine paths, see How to Set Placement Options for a Host.

· If you chose Store the virtual machine in the library, specify the library server that will store the virtual machine, and then select a path on the available library shares to store the virtual machine's files.

The wizard will continue with the Summary page.

Select Networks

Attach the physical network adapters to either Not Connected or to any of the virtual networks on the selected host.

Additional Properties

On the Additional Properties page, accept the default settings, or modify these settings as described in How to Configure Automatic Start and Stop Actions for a Virtual Machine

Summary

Review the configuration settings. To change settings, click Previous.

Optionally, click View Script to view (and copy) the Windows PowerShell script that runs this wizard and performs the conversion. All administrative tasks in VMM can be scripted or performed at the command line. For more information, see Windows PowerShell Scripting in Virtual Machine Manager 2008 (https://go.microsoft.com/fwlink/?LinkId=110911).

Optionally, select the Start the virtual machine after deploying it on the host check box.

In Jobs view, monitor the progress of job as the new virtual machine is created and confirm that the virtual machine is created successfully. If the job fails, review the error message at the bottom of the Jobs pane for information about the cause of the failure and the recommended action to resolve the issue.

See Also

Concepts

Creating New Virtual Machines

 

 

 

 

Comments

  • Anonymous
    January 01, 2003
    thank you
  • Anonymous
    January 25, 2013
    Hi Jonathan, in your post, you say: "when creating a virtual machine from a template, you must choose the Place the virtual machine on a host option. " Actually, you can select to deploy it to a cloud and it works fine. The only issue I have is that it won't start the VM automatically, as it does not give you the option to choose during the deployment. However, if you deploy a Service Template to a clould, the VM(s) start automatically. Any tips on that matter? JF