Donnerstag, 10. Juni 2010

How to manually merge Hyper-V snapshots into a single VHD

Okay, so you have to recreate your VM configuration and you absolutely know that your VM had a snapshot at some time.You also realize that if you just link to the base VHD that you will lose the current state of your VM - what do you do?You manually merge your snapshots into your base VHD before you boot your VM. (I am assuming that you know how to connect to an existing VHD using the new VM wizard).Merging of snapshots can be performed manually. This is achieved by:On your Hyper-V host.Power off the Virtual Machine.Make a copy of the VHD and its corresponding AVHD files.Rename the AVHD extension to VHD.Write down the order of the disks from youngest to oldest (the oldest should be the root VHD). You can do this by looking at the last modified time stamp on the origional AVHD files, find the one that last changed. And find the last one that changed before it.In the Hyper-V manager, open the Edit Disk wizardBrowse to the youngest VHD in the chain, then choose 'reconnect' to point to the next youngest (the one that came before).Open the Edit Disk wizard a second time and merge.Then repeat the process until you have only a single VHD.In a disaster case, you need to recover a copy of the root VHD prior to attaching it to a new VM and booting it (the act of booting it, modifies it)Usually the most difficult part of this process is finding the last AVHD (differencing disk) in the chain.The easiest way to do this is to find the configuration file for the VM.