This is a brief chronicle of the effect of re-creating a Virtual Machine from a Virtual Hard Drive that had Snapshots taken and not merged back into the parent image.
Background
In August 2010, I created a Hyper-V lab with a Windows 7 development VM and a Server 2008R2 testing VM. The VM hard disks, virtual machines, and snapshots were stored on the SATA hard disk. The Hyper-V Server 2008R2 host was installed on a bootable USB pen drive.
Apparently around November 2010 and over the course of 2011 I created a few snapshots of the Windows 7 VM.
Fast forward to a couple weeks ago
My Hyper-V environment lost power and when it restarted the BIOS failed to recognize the Kingston USB pen drive that Hyper-V was booting from. Result: My lab was down. This happened one other time, but after some fiddling with the BIOS, I was able to get the USB drive to be recognized.
In order to prevent this from happening in the future, I replaced the USB pen drive by installing Hyper-V Server 2008R2 on an IDE drive, plugged it into my lab box and booted. I created a new Virtual Machine using the existing Window 7 Virtual Hard Drive and powered up my development VM. Upon a quick glance everything looked fine.
Missing Files and Programs
A few days later while logged into my Dev VM, I noticed several of my files and directories were missing, Microsoft Office wasn’t installed, and SQL Server said the trial had expired. What?!?
A quick check of the Windows Event log and there was an entry that Windows was not shut down properly on November 11, 2010, but was back up and running on Feb 12, 2012. Suddenly I was missing over a year of development activity; not really.
Don’t Panic!
November 11, 2010 was the date the first snapshot was taken. All the activity since then was in the snapshot differencing disks (3 files with a .AVHD extension).
I had a Windows Image Backup and regular full backups, but instead of restoring from backup, I decided to have a little fun with the Hyper-V management console instead.
A little research and I found this article about merging differencing disks. It isn’t the best reference you can find because it doesn’t have screenshots of the process like this one. I actually backed up the parent VHD and child AVHD files and renamed the AVHD files VHD, but it appears the renaming process is unnecessary. Otherwise after using the Hyper-V management console to merge each of the AVHD files to their parent drives, I powered up the dev VM after merging and everything was back to the state prior to the initial power outage. Success!
Moral of the Story
If you use a Hyper-V snapshot to test a Windows Update or some other configuration change that you want to be able to roll back out of, make sure to merge the snapshot back into the VM. Don’t leave it in a snapshotted state. Especially not with multiple active snapshots.
photo credit: pnoeric / CC BY-SA 2.0