I believe in Hyper-V!

Prepare Hyper-V virtual machine image for cloning

In one of my previous posts I explained how to Clone a virtual machine with the Virtual Machine Manager, but before Clone our virtual machine we need prepare the virtual machine for cloning.

As you probably know by now, Microsoft-based operating systems use SIDs (Security IDs) that are generated as part of the initial setup of Windows. If you have more than one computer with the same SID, this could cause problems, and cloning a computer (either physical or virtual) without re-generating this SID can cause SID duplication.

Due to the above, we need to prepare virtual machine image for cloning.
This guide assumes that you’ve got some sort of virtualization infrastructure in place. In my case this is a Microsoft Hyper-V. It also assumes that you’ve got some sort of virtualization management tool like System Center Virtual Machine Manager.

In addition, it’s important that you have a basic knowledge about how to set up and run your virtualization product, that you are knowledgeable about setting up virtual machines, and about the proper procedure to install and configure a Windows-based operating system on these virtual machines.

Also, , this guide assumes that you’re knowledgeable about the proper procedures needed to be taken prior to creating a virtual machine clone, how to use SYSPREP (the system preparation tool from Microsoft), and how to create proper answer files for the preparation procedure.

In this post I ‘ll describe how to prepare virtual machine images for Windows Server 2008 R2 and Windows 7.  In Windows Server 2008 R2 and Windows 7 the SYSPREP tool is already included in the operating system, therefore there’s no need to download it like for Windows XP.
To create the proper answer file under Windows Server 2008 R2, Windows 7, you need to either manually edit an existing answer file, or create one for your needs.
To create an answer file for Windows Server 2008 R2 or Windows 7, you must use the tools available in the Windows Automated Installation Kit (AIK) and you can download here.

Preparing the System for Cloning

Prior to cloning the virtual machine there are several steps that you need accomplish. This is not a requirement but is recommended.

  • Log on to the computer as an administrator.
  • Install and customize applications.
  • Customize the Default User profile.
  • Update Windows and other software components.
  • Clean temporary files.
  • Defragment the disk, and compact the VHD file.

Create the UNATTEND.xml Answer File for Windows Server 2008 or Windows 7

Unattended Windows Setup answer file in Windows Server 2008 R2 and Windows 7, is an XML file typically called Unattend.xml. This is the answer file for Windows Setup that is created by using Windows System Image Manager (Windows SIM). The answer file enables the configuration of default Windows settings, as well as the addition of drivers, software updates, and other applications.
The unattended Windows Setup answer file in Windows Server 2008 R2 and Windows 7 needs to be specified during the running of SYSPREP. To do so, run the SYSPREP tool with the /unattend:filename option.

If you wish to manually configure the Windows settings after SYSPREP, run SYSPREP from the C:\Windows\System32\sysprep folder.

1

Make sure you do NOT FORGET to select the “Generalize” option if you need to change the computer’s SID. It seems that this version will NOT change the SID unless you pick that option.

2

Sysprep is working.

3

When the process is complete the virtual machine will shut down.

OK, our VM is prepared for Cloning and if you want to know how to Clone VM with System Center Virtual Machine Manager read my previous post about that.

After starting cloned machine, you will be prompted to configure few settings like the user name, computer name, language and some other settings.

4

I need to mention, creating an answer file will greatly ease this process, and the entire process will automatically run.

Folks that’s it!

8 Responses to “Prepare Hyper-V virtual machine image for cloning

  1. I just like to add SID duplication is not and has never been a problem, yet that myth still lives on. See this article by Mark Russinovich (author of the NewSid utility):

    http://blogs.technet.com/b/markrussinovich/archive/2009/11/03/3291024.aspx

    • Yes, you have a right but, if duplicated, can cause problems for certain applications like Windows Server Update Services (WSUS), so Microsoft’s support policy will still require cloned systems to be made unique with Sysprep. Writing at the end of this article; http://blogs.technet.com/b/markrussinovich/archive/2009/11/03/3291024.aspx
      Thank you for your comment.

    • Kyle

      It is still very much a problem. Try setting up an Exchange DAG or a SQL cluster with a couple of cloned VMs. It won’t work. You HAVE to sysprep your clones first or else you WILL have problems with various software. The only thing that doesn’t need it anymore that used to need it is AD. I see the myth ABOUT the myth still lives on…

  2. Errol

    Awesome posting!

  3. Vadim Chetverikov

    As it comes from my experience, SID duplication is THE ONLY problem. Nothing deadly happens if you try to run cloned machine along with a clone master in same network. You’ll just get a warning that same computer name already exist in your network, so it would be the first thing you have to change – the name of cloned machine. Not a big deal.
    The second (optional) issue – duplicated IP address. Same action – just change it. But this is avoidable if you set master’s IP as “Obtain automatically” (via DHCP). That’s what I do for clone’ masters. The Static IP should be set for target machine after cloning (if required).
    As per same SID – it works fine untill you’ll try to join newly cloned server to Domain Controller, which still has same SID, inherited from Clone Master. Then you’ll get into troubles, given new server will join the domain, but will not allow you to log in, poping up a message about SID duplication problem.
    For some reasons (unknown to me) the SID problem doesn’t rise up for workstations (at least I never faced it so far). So I never altered SIDs for workstations.
    So, what I use to do:
    I never run any sysprep BEFORE cloning.
    I just clone the machine, which I call “Clone Master”, which is just newly installed and updated virtual machine. With all “gentleman pack” apps installed too (kinda WinRAR, Acrobat and so on). And it’s IPs are all set to dynamic (via DHCP).
    And after that only I use to run “NewSID” utility (borowed from SysInternals) on new cloned machine to avoid mentioned potential problem of joining it to domain.
    I didn’t try this procedure in Hyper-V environment yet, but it works fine in vmWare and VirtualBox.

  4. Mark

    Scenario:

    === “Production” VM that is configured and domain member — this VM has the configuration that I want to multiply

    Would it work to:

    1) clone this VM from shutdown Production VM using SCVMM
    2) start this copy and run sysprep in it
    3) save this copy as my new clone master

    ?

    Just curious as to whether anyone has gone this route…

  5. Well, Mark wrote indeed the article under the aspect of security. If you try to add a machine with a duplicate SID into a domain under Windows Server 2012 R2 you need to resolve the problem in the way given above.

Leave a Reply to Romeo Mlinar Cancel reply

Your email address will not be published. Required fields are marked *