Cloning Hyper-V Virtual Machines the Right Way (Part 1)

by [Published on 14 Oct. 2009 / Last Updated on 14 Oct. 2009]

How to avoid disaster by creating a virtual machine clone properly.

If you would like to read the other parts in this article series please go to:

Introduction

Although it is relatively easy to make a clone of a virtual machine, the cloning process is less than intuitive. This article series shows you how to avoid disaster by creating a virtual machine clone in the proper way.

You have probably heard that server virtualization products such as Hyper-V make it easy to clone virtual server images or to move virtual servers to new hardware. However, if you ever actually tried to build a server image and then clone it, you might have been surprised by how non intuitive the process actually was.

The first time that I ever had to create a virtual machine clone, I was a little taken back. All I kept hearing about was how easy the process was. Because of that, I really expected the Hyper-V Manager to have a Clone Virtual Machine button. As you have probably already guessed though, such a button simply does not exist.

Since that time, I have tried a lot of different methods to cloning virtual machines. Some of them have worked, and some of them have not. Since there are so many techniques that you could potentially use, I wanted to take the opportunity and explain which cloning techniques actually work, and why.

The Challenge of Cloning Virtual Machines

Before I get started, I think that a little explanation of the challenges involved in cloning virtual machines is in order. The problem with cloning a virtual machine is that you can not have two identical computers on the same network. You can have machines that are almost identical, but they can not be 100% identical. The reason for this is that certain machine attributes are used as a means for identifying the machine on the network. Therefore, if you have two machines that are completely identical, then networking ceases to function. In case you are wondering, some of the things that have to be unique for each computer include:

  • The Windows Security Identifiers (SIDs)
  • The Media Access Control (MAC) address
  • The Internet Protocol (IP) address
  • The NetBIOS and Fully Qualified Domain (FQDN) names

Given that some system attributes are required to be unique, simply copying virtual hard drive files and building another virtual machine around them will not work. Out of curiosity, I actually tried to shut down a virtual machine, copy its files to another location, and create another virtual machine using those files. When I booted the new virtual machine I received the Blue Screen of Death.

As you have probably already figured out, successfully duplicating a virtual machine requires stripping any attributes that are required to be unique from the clone. There are at least two good ways of accomplishing this.

The SYSPREP Utility

The first of these methods involves using the SYSPREP utility. The SYSPREP utility is actually ideally suited to the task of cloning virtual machines, because it was specifically designed to prepare Windows for duplication.

Before I Begin

Before I show you how to use the SYSPREP utility, I need to point two things out. First, if you are familiar with my work, then you know that I like to keep things as simple as I can. Nobody needs to read a needlessly complex article when they are just trying to get a job done. Having said that, there are all kinds of cool things that you can do with the SYSPREP utility. Even so, I am going to be sticking to the basics, because that is all that is required for accomplishing our goal.

The second thing that I need to point out is that SYSPREP has been around for a long time, and has evolved a bit from one version of Windows to another. The technique that I am about to show you was designed for use with Windows Server 2008. There is a Windows Server 2003 version of SYSPREP, and it can be used to clone a virtual machine that is running Windows Server 2003 (I have actually done it). Keep in mind that the SYSPREP specific steps are going to be different than what I am about to show you though.

If you need the Windows Server 2003 version of SYSPREP, it is included on the Windows Server 2003 installation CD as a part of the Support Tools. The Support Tools are not installed by default, but you can find them in the CD’s \Support folder.

Preparing for SYSPREP

Before we actually begin using SYSPREP, there are some rather important things that you need to know. First, even if you do not remember anything else that I have said in this article, there is one extremely important thing that you need to keep in mind. Do not run SYSPREP on a production server under any circumstances!

OK, I know that statement is probably a little confusing. After all, our goal is to clone some virtual machines, right? Well, the reason why it is so important not to run SYSPREP on a production server is because SYSPREP will destroy Windows. Well, not completely, but trust me… You do not want to run SYSPREP on a production server.

When you run SYSPREP, it prepares the server for duplication. That means stripping the server’s SIDs, and the other types of attributes that I mentioned earlier (the MAC address is an exception, but I will address that later in the series). With these attributes gone, the server is no longer able to function as it previously did.

Of course this raises the question of what good an image is if it is based on a non functional server. The way that Windows gets around this issue is by prompting you to answer a few questions the next time that you boot the server (or any clones of the server).

What happens is that Windows preserves most of your deployment settings. Since it is missing a few things though, the first time that you boot your original virtual machine or one of the clones that was made from it, Windows runs something that I like to think of as a miniature Setup Wizard. This wizard asks you a few basic questions, and then Windows is rebuilt.

Although the Setup Wizard behaves as though you are installing a completely fresh copy of Windows, most of the modifications that you have made to the virtual machine prior to running SYSPREP will be preserved. For example, any folders that you have created on the hard drive will still exist. Applications will still be installed, and so will patches.

Since the SYSPREP process does scrub some attributes from the machine that is being duplicated, it is possible to cause some problems if you are not careful. In the next part of this series, I will talk about some of the things that you can do to prepare a virtual machine for duplication in an effort to avoid such problems.

Conclusion

In this article, I have introduced you to the SYSPREP tool, and I have begun discussing some of the things that you need to do in order to prepare a server for duplication. In the next part of this series, we will talk about a little bit more prep work that needs to be done, and we will create a virtual machine image.

If you would like to read the other parts in this article series please go to:

Advertisement

Featured Links