Sunday, June 10, 2012

Hyper-V How to Create a Virtual Machine Template

 

Written by Joseph Piggee

With all the updates out there, it can take quite sometime to get a a new Virtual machine up and running. To save yourself some time, create a base template. With Hyper-V and using sysprep, it’s pretty quick & easy. You’ll want to use sysprep in order to generate a different SSID & MAC address. Sysprep in now included with Windows 7 & Server 2008 R2. Sysprep can be found in %systemroot%\Windows\System32\Sysprep.

* Note: When you run sysprep, be sure to select the OOBE option.(OOBE=Out Of Box Experience)

  1. First create your virtual machine, and install all applicable updates.
  2. Set all default settings:
    • Workgroup or Domain membership
    • Update settings
    • Enable RDP
    • Disable unnecessary Services
  3. Power off you VM, and backup your VHD.
  4. Now power on your virtual machine.
  5. Open a command line, and navigate to the sysprep directory.
  6. At the prompt type: sysprep /oobe /shutdown.

clip_image001

The alternative is to just type sysprep with no options, and you’ll get a GUI, which I will show below.

  • Example of sysprep GUI:
    1. Open command-line
    2. Navigate to %systemroot%\windows\system32\sysprep
    3. At the command prompt type: sysprep
    4. press enter
    5. You’ll see the Sysprep gui popup.
    6. clip_image002
  • Select the following:
    • Enter Stem Out-Of-Box Experience (OOBE)
    • Check Generalize (This will generate a new SSID)
    • ShutDown
  • Click OK
  • After the VM shuts down, make a copy of the VHD. I’d recommend marking as read-only so you don’t accidentally boot from it and alter it.
  • That’s it your done.

To create a VM from you template, using best practices, create a directory for your new server. For my example, the server name will be Server03.

  1. Copy the the VHD template you created in step 7 above to your new directory. In my case, I copied my template VHD to a directory called Server03.
  2. Changed the read-only attribute.
  3. From inside your Hyper-V manager, right-Click your Hyper-V server, Select New –> Virtual Machine
  4. The New Virtual Machine Wizard will open.

clip_image003

  1. Type in the name of your Server, Select store VM in different location
  2. Browse to the location where you copied the VHD intended for this installation.
  3. Click Next.
  4. Configure the amount of memory, click Next.

clip_image004

  • If necessary, connect network. Click Next.

clip_image005

  • In this section, this is where you select, Use existing virtual hard disk. Browse to the VHD for this installation. Click next.

clip_image006

  • Then click Finish.

clip_image007

  • Now start your new VM.
  • You'll encounter the usual prompts as shown below.

clip_image008

clip_image009

clip_image010

clip_image011

2 comments: