Udostępnij za pośrednictwem


Recovering a Hyper-V virtual disk (with its snapshots)

 

My work at Microsoft involves using lots of Virtual Machines and snapshotting their states along the way. Every now and then the physical host machine needs to be reimaged, and not always the virtual machines have been exported (to be imported back, if needed).

So here is a way to recover from this potential catastrophe:

For simplicity, let's say that you have a original virtual disk and two snapshot disks:

· Let's say the original disk is called baseDisk.vhd

· The first snapshot (snapshot1.avhd)

· The second snapshot (snapshot2.avhd)

Now follow this process:

1. Rename snapshot2.avhd to snapshot2.vhd

2. In Hyper-V Manager, merge snapshot2.vhd into snapshot1.avhd using the "Edit Disk“ function

3. After completion, rename snapshot1.avhd to snapshot1.vhd

4. Merge snapshot1.vhd into baseDisk.vhd

5. Now the based VHD (baseDisk.vhd) is updated with all changes.

If there are more snapshots, just do step 1 and 2 for all previous snapshot file, starting with the last snapshot file created (the one with the most recent date of creation).

One important thing: after a successful merge, the snapshot file which has been merged will be deleted without prior notice! So if you want to be on the safe side, back it up before!

The principle behind the snapshots is that each snapshot (child) just knows about the preceding snapshot or base VHD (parent). You can verify that by using the "Inspect Disk” function.

Please, do note that this process is very, very time consuming. :)

Now you just need to create a new Virtual Machine and use the originalDisk.vhd as its virtual disk.

I hope it helps!

For more, see: https://blogs.msdn.com/b/robertvi/archive/2008/08/26/howto-recover-snapshots.aspx

Comments

  • Anonymous
    November 10, 2010
    The comment has been removed