Saturday, July 6, 2013

Hyper-V VM linked Clone - Doing it the right way - I

Missing the easy VMWare workstation Linked Cloning feature in Hyper-V client ?
Part I describes how you can do the same, saving huge disk space and the most important without messing up your Virtual Machines.

Part II will guide you through special steps required for virtual Windows Server 2012 Domain Controller cloning since it becomes virtualization aware not like previous windows releases.

Before proceeding on this post I do recommend quick reading on the following areas if you are not familiar with it:

What is Sysprep?

Create Hyper-V Virtual Machines

Linked Clone VM, when you have one master virtual machine as reference configuration and left intact using it's hard disk image for other machines too, for instance assume we have 21 Windows Server 2012 VMs, if single VM's hard disk image requires about 15GB of storage for Windows installation purposes only, by using this scenario we will link the all remaining 20 VMs to the first VM's hard disk image saving (theoretically) 20VM X 15GB which results in 300GB  of your lab storage..! do not be panic, there is no extremes between theory and real life implementation.

The idea is mapping all VMs you have to an existing vHDD and by time you are operating each of these cloned VMs, each one start creating separate file as a complementary disk image submitting all the Guest OS changes happened since the clone VM created and should be written to the machine's vHDD. leaving the original vHDD intact which used as template and as reference for the rest VMs.

Imagine that you can make VM having a sysprepped Windows Server 2012 installation and Role\Feature free. which can be used then as template for future uses for any other Windows Server 2012 you require in your testing environment. All upcoming Guest Windows server changes, added Roles and Features would be written separately in a different .avhdx file leaving the template .vhdx (hard disk image) intact as described above.

DISCLAIMER: I am expressing my own opinion and experience which not necessarily assure that this is suitable for production environment.

One last important note before we can proceed,  this is not the recommended cloning method for virtual domain controllers.

  • SYSPREP the machine that will be used as Template

browse to Guest OS (\windows\system32\sysprep), check "Generalize" then shut down the Template VM.

• Copy the .vhdx for the machine that will be used as template.

• Delete the Template VM from Hyper-V manager console, this will save you from accidently power on the Template VM and do unneeded changes (Recommended). 

• Compact the disk using the Hyper-V Manager to make it as small as possible (optional).

• Mark the common disk image as read only to prevent accidental changes and corruption to VMs using it (Recommended).

• Create a new VM (which considered the clone) and assign the Template disk image to it as existing hard disk image during creation wizard and DO NOT POWER ON it!.

• Now here is the trick, Firstly and immediately make a snapshot of the new clone VM. All disk changes will from now on be written to a differential disk specific to this clone VM.

• Since the Template .vhdx would be untouched now, you can safely boot the new clone VM.

No comments:

Post a Comment