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

by [Published on 11 Nov. 2009 / Last Updated on 11 Nov. 2009]

One method you can use in order to clone virtual machines.

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

Introduction

In my previous article in this series, I explained that cloning a virtual machine is not quite as intuitive as you might have been lead to believe. Part of the reason for this is that in order for the cloning process to be successful, you need to use Sysprep to strip certain attributes from the host that is being cloned. In this article, I want to continue the discussion by showing you one method that you can use for cloning virtual machines.

Running Sysprep

As I mentioned in my previous article, in Windows Server 2003, Sysprep was included in the Windows Support Tools, and it therefore had to be installed manually before you could use it. In Windows Server 2008 though, Sysprep is installed by default. You can access Sysprep by going to C:\Windows\System32\Sysprep and running Sysprep.exe. When you do, you will see a screen that is similar to the one that is shown in Figure A.


Figure A: This is what the SYSPREP interface looks like

As you can see in the figure, the Sysprep interface is pretty simple, but even so it is very important to pick the correct options. Otherwise you could find yourself having to go through the configuration and preparation process all over again.

The System Cleanup Action drop down list contains two options; Enter System Out of Box Experience (OOBE) and Enter System Audit Mode. You must choose the Enter System Out of Box Experience (OOBE) option. Next, you must select the Generalize check box. Otherwise, the system will not be stripped of its uniquely identifying attributes. Finally, you must set the Shutdown Options to Shutdown. It is important that you select Shutdown and not Restart. If you use the Restart option, then the recently generalized system will reboot and enter into Windows mini-setup mode, effectively undoing your prep work.

Cloning the Image

Now that you have generalized the system image, it is time to begin the cloning process. The first time that I tried to clone a virtual machine, I thought that once Sysprep had shut down the virtual machine I would be able to simply copy the virtual hard drive file to another location, and then build a new virtual machine around the copy of the virtual hard drive file. I was able to make a variation of this technique work for a virtual server that was running Windows Server 2003, but I could not make it work for Windows Server 2008. Every time I tried to boot the cloned virtual machine I received the blue screen of death. Fortunately, there are other methods for cloning virtual machines.

The first method that I want to show you involves using System Center Virtual Machine Manager. In case you are not familiar with System Center Virtual Machine Manager, it is a utility for managing Hyper-V servers. This is not a free utility though, so if you do not own a copy of System Center Virtual Machine Manager, do not panic. I am going to show you another cloning method that you can do without this utility.

To begin the cloning process, open the Virtual Machine Manager console and select the Virtual Machines node from the pane on the lower left side of the console screen. This will cause the console to list all of the virtual machines that are installed on the currently selected Hyper-V server. Now, locate the server that you just ran Sysprep on. Right click on the listing for that server, and choose the Clone command from the resulting shortcut menu, as shown in Figure B.


Figure B: Right click on the virtual machine that you want to clone and choose the Clone command from the shortcut menu

The console will now launch the New Virtual Machine wizard. The wizard’s first screen will ask you for a name and description for the new virtual machine. Keep in mind that if you are going to be setting the new virtual machine up on the same host server that is running the server that you just cloned, then you will have to use a different name. You can see an example of this in Figure C.


Figure C: Enter a name for the new virtual machine that you are creating

When you have finished entering a name and a description for the virtual machine, click Next. You will now be taken to the Configure Hardware screen that is shown in Figure D. As you can see in the figure, this screen is similar to the Settings screen found in the Hyper-V Manager. You can manually allocate hardware resources to the new virtual machine, or you can allocate hardware resources by making use of a hardware profile.


Figure D: You must allocate some hardware resources to your new virtual server

Click Next, and you will be taken to the New Virtual Machine Wizard’s Select Destination screen. As you can see in Figure E. As you can see in the figure, you must choose whether to place the new virtual machine on a host or to store the virtual machine in a library. The choice is yours, but most of the time if you are going through the trouble of cloning virtual servers you are going to end up placing the cloned machine in the library.

What happens next really depends on the option that you select on this screen. If you choose to place the server into a library then you will be prompted to enter the name of a library server and a path. If you choose to host the virtual machine then you will be required to specify a host, a path, and specify how the virtual machine will connect to the network.


Figure E: You must choose whether to place the new virtual machine on a host or to store the virtual machine in a library

Booting a Cloned Image

Now that the cloning process is complete, it is time to boot our cloned virtual machine. When you initially power up the virtual machine, you will be taken to the Windows Server Setup screen, as shown in Figure F. Do not panic! Windows needs to run a miniature version of Setup so that it can regenerate the attributes that we stripped earlier.


Figure F: Windows launches a mini version of Setup

Select your region and your language just as you would for any other Windows installation, and click Next. At this point, Setup will display the Windows license agreement, as shown in Figure G. Go ahead and accept the license agreement, and click Next.


Figure G: Accept the license agreement and click Next

The final step in the process is to enter a new name for the new virtual server, as shown in Figure H. After doing so, just click the Start button and Windows should boot. You should now have a fully functional cloned machine. It is possible that there may be some other minor configuration work that you will have to do though. For example, if you use static IP addresses on your servers then you would need to assign an IP address to the new virtual server before you would be able to use it to access the network.


Figure H: Enter a name for the virtual server and click Start

Conclusion

In this article, I have shown you how you can use Sysprep to prepare a virtual server to be cloned, and then I showed you how to use the System Center Virtual Machine Manager to perform the cloning process. In Part 3 I will show you an additional cloning technique that you can use if you do not happen to own a copy of System Center Virtual Machine Manager.

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

Featured Links