Moving A VM With Differencing Disks

I’ve a lab machine running Hyper-V.  I’ve a number of lab machines on there, all using differencing disks.  I’m budget conscious with this machine so I use a single internal disk partition to store VM’s and the source disks for the differencing disks.

I needed to move two of these lab VM’s onto another server.  I don’t manage the lab machine with VMM (I’ve previously referred to a VMM agent refresh issue which PSS are looking into) so I did a manual move.  I set up VM’s without hard disks on the destination host.  I powered down the VM’s on the source host.

Watch out for snapshots!  I had snapshots on the lab VM’s.  Snapshots are differencing disks.  When you take a snapshot, a new differencing disk is created behind the scenes.  It uses your VM’s disk as a source disk.  All changes following the snapshot are stored in the differencing disk.  If I had copied the VHD of the VM disk to the new host server then I’d lose everything since the snapshot.  The solution?  Copy the VHD to keep it safe so you have something to rollback to (if you need to do this).  Delete the snapshot to trigger a merge.  Anything in the snapshot will be merged back into the VM’s VHD.  Now you can copy this file to the destination server …

… but not if the VM’s disk was a differencing disk!  Otherwise when you bind it to the new VM and power it up you get an alert:

"VM001: Failed to open virtual disk …. A problem was encountered opening a virtual disk in the chain of differencing disks, ….. (referenced by ….): ‘The sytem cannot find the file specified.’ (0x80070002). (Virtual machine …..)".

That appears in the event log in Application Logs and ServicesMicrosoftWindowsHyper-V-WorkerAdmin as an Error with a source of Hyper-V-Worker and an event ID of 12142.

The solution is simple.  Edit the disk’s properties on the source VM.  Edit the disk and select "Merge".  This will give you two options:

  • To the parent virtual hard disk: In this scenario you do not want to do this.  This will save changes to the source virtual disk that many of your other VM’s may be using.  Not good!
  • To a new virtual hard disk: This will create a new VHD file in a selected location.  This is the one to use in this scenario.

You now can create either a fixed size (required for production) or dynamic VHD.  This will run pretty quickly.  Once complete you can copy the VHD to your destination host server and bind it to the VM.

One thought on “Moving A VM With Differencing Disks”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.