First rule. DO NOT Take a Snapshot in your Production environment. Avoid it at all costs whether it’s VMware or Hyper-V. It’s a massive risk to the data if corruption occurs.
Now if you IGNORED this rule or you HAD to do something that INSISTED on this happening, don’t sweat it.
The problem is sometimes we (as humans) make mistakes. The snapshot gets taken *and* get’s forgotten about. So you have to Merge it.
Normally in Hyper-V if you do a shutdown of the Virtual Machine, the environment WILL automatically start merging. This is the norm.
But factors can affect this. Space, Murphy and the Unknown are the uncontrollable factors we Professionals have to deal with. However it’s good to know there is a fallback. You can do it manually.
Yes, manually. Now no matter how much data you have, no matter how long it takes… BACK IT UP FIRST!!!
I say this because you always (no matter your skillset, no matter what you think SHOULD happen) you have to plan for the UNexpected. Power outage, corrupt files on the server, the Host dying during the process. Fortunately in my experience Hyper-V is well designed for the unexpected.
Let’s also think about just what an AVHD file is. It is closer to a list of transactions than a virtual hard drive. So when Hyper-V goes to merge the data, it is examining the transactions and building the drive structure to commit it. If you lose power, you still shouldn’t lose data.
But if you need to do a manual merge (Perhaps you would like to rebuild those files offline to avoid issues?) this is also a simple process. (Although scary the first time you try it!)
Rename all the “AVHD” files to VHD
Go to Hyper-V and choose “EDIT DISK”. Browse to the folder of the files.
Find the NEWEST file (That was an AVHD and is now a VHD) and select it.
You MAY get an option to “Reconnect to Parent”. This can be normal if you have MULTIPLE Avhd files. Take note of the ORIGINAL filename and connect to that file in your current folder (if you read the screen Hyper-V is actually prompting you). The AVHD’s refer to the original VHD (if they are the first Snapshot *or* they will refer to the PREVIOUS Avhd file.
If you get a Reconnect, the choose the proper file and back to EDIT and REselect the Newest file again. You will now be presented with “Compact” or “Merge” as your options. Choose “Merge”
Let the file Merge (Depending on the size it could take a bit, don’t worry and don’t panic)
Repeat the process going back a file and back a file until you only have you VHD
If you’re concerned about the content afterwards and don’t want to chance a boot, Remember in Server 2008R2 and Server 2008 in DiskMgmt you can attach the VHD in Readonly mode to verify the content.
Now in my case my Hyper-V files are well organized. You may find out yours are still in the default location like C:\ProgramData\Microsoft\Hyper-V . But one of the nice things about the AVHD files (Snapshots) is they mimic the name of the VHD file. so if your Parent VHD was called
you’ll find the AVHD files will have names like.
If you have to go digging, you usually don’t.
Also some more details I found out.
600 gigabytes on a Strong Raid 5 controller over SAN is about 6 hours to Merge. I found similar numbers when working directly from Raid 5 Sata drives.
It will Merge One AVHD file at a time. this is Good to know because if you’re watching you WILL actually see the AVHD files disappear, Newest to oldest. (As the Newest is Merged INTO it’s predecessor)
It does NOT build a “NEW” Vhd file, so disk space (As far as I can tell) is NOT an issue unless the parent is meant to “Grow” in the process. But between the Parent and the Removed child, you should be ok…
So just remember. Don’t panic if you have a massive amount to Merge. It will happen. If you’re nervous, copy the files ELSEWHERE and begin doing a Manual merge of the backups in Hyper-V. The good part there is you can mount it all afterwards to verify the status.
…. Most of all just be cautious, but be confident. It will all work out.