Getting UNDO functionality with Hyper-V Snapshots

Snapshots are not the same as UNDO disks in Virtual Server 2005…go here to read a previous post of mine to learn about how they work.

That said, you get UNDO like functionality using snapshots…..with maybe a little more work.

In Virtual Server, when you wanted to use UNDO, you powered down your VM and enabled UNDO on the Virtual hard disk tab. Then after you power on the VM, when you powered it off you will be asked if you want to Save, Commit, or Discard your changes. Selecting Save kept the changes separate, Commit merged them into the original VHD and then started the UNDO process over again, and Discard threw away the changes and started over again. All of this used Differencing disks in the background.

In Hyper-V, UNDO is not an available option on the virtual disk menu anymore, you now have snapshots. If you want the ability to protect your VHD from any changes getting merged you need to do this.

Before you first power on a VM (the same point you would have enabled UNDO in Virtual Server), take a snapshot and call it something like UNDO DISCARD. This just makes your VHD effectively read only and all changes are written to a working AVHD file.

Power on your VM and work away.  When you want to effectively “Turn OFF and Discard” all changes, then apply/revert to the UNDO DISCARD snapshot and it is all gone…start a new test scenario. Just remember that if you made any changes to the VM settings, they are also discarded.

By default all changes are saved to the working file, so you need to do nothing to get the SAVE feature.

If you want a COMMIT capability and want it permanent like it is with Virtual Server, then that takes a little more work.   Once you create the UNDO DISCARD snapshot, there is no way to merge any changes back to the original VHD through the snapshot UI. 

You can do the following though to get the COMMIT functionality

  1. Power down the VM
  2. Find the working avhd file
  3. Copy it to CHILD.VHD
  4. Backup up your original VHD for protection
  5. Use the Edit disk option in Hyper-V MMC to edit the new CHILD.VHD and select Merge for the action in the wizard
  6. Select to Merge to the parent
  7. Wait for the merge to complete
  8. Apply the UNDO DISCARD Snapshot (which throws away all the changes which you just merged from the copy and creates a new working avhd file that is the child of the original VHD)
  9. Power on the VM and work away

Once again remember that if you had made any changes to the VM settings, that applying the UNDO DISCARD snapshot would have thrown them away…..other than that have fun!!

Let me know if you have any issues...