Consolidating Hyper-V Differencing Disks into One

I deleted two snapshots from a Hyper-V virtual machine (VM) this morning.  This left the base .vhd file and two .avhd differencing disks.  I decided I wanted to merge them into a single file and learned that the diskpart tool will let you do this.

  1. Open an elevated command prompt (i.e. run as administrator).
  2. Run diskpart.
  3. Enter: select vdisk file=”<full path to the latest differencing disk>”
    1. A differencing disk ends in either .avhd or .avhdx.
  4. Enter: merge vdisk depth=n
    1. n will be the number of parent files you want to merge.  Since I had two parents, one .vhd and one .avhd for this .avhd file, I used depth=2.

Happy merging!

Rob

This post was migrated from https://blogs.msdn.microsoft.com/rob/2013/04/03/consolidating-hyper-v-differencing-disks-into-one/.