Merge Differencing Disk to HyperV Host

Merge differencing disks (AVHD/AVHDX) to boot Hyper-V machine

I have had a torrid time merging differencing disks (AVHD/AVHDX) to the original boot HyperV machine problem. These files occupy most of the space on the host machine causing all the virtual machines running on the host to go into a pause state.

It is imperative to take a backup of the virtual machine concerned before running the merge process. The steps provided below do not guarantee a successful merge of the AVHD/X to the VHD/X.

Please find below steps to resolve the problem at hand:

  1. Select Hyper-V server in Hyper-V Manager
  2. On left-hand side, select Inspect Disk
  3. Browse to location of restored AVHD/AVHDX files
  4. Select one of the AVHD/AVHDX files > OK
  5. Record parent disk name
  6. Repeat steps 2-5 for each AVHD/AVHDX file, and record their order (from newest to oldest)
    • Note: do not use timestamps to determine which files to merge, as this could lead to overwriting the incorrect parent file
  7. Select Hyper-V server in Hyper-V Manager
  8. On left-hand side, select Edit Disk
  9. Next > Select newest AVHD/AVHDX file
  10. Followed by Next > Select Merge
  11. Next To the parent virtual hard disk
  12. Finish
  13. Repeat steps 7-12 for each AVHD/AVHDX disk, until only the VHD/VHDX disk is left for the machine
  14. Mount VHD/VHDX in new virtual machine in Hyper-V and boot

In order to merge the files using PowerShell, you can use the below steps:

  1. Open PowerShell and run command to navigate to directory where AVHDX and VHDX files are located:
    • Note: if files are on different disk than C:, first change to correct disk with disk letter in PowerShell prompt:
      • <disk letter>:
      • For example, if data is located on drive D:, command would be:
        • D:
    • To change to correct directory:
      • cd <directory path where files are located>
  2. Run following command on each AVHDX file:
    • Get-VHD .\<name of AVHDX file>.avhdx
  3. Note name of parent AVHDX file from ParentPath entry in output
  4. Repeat steps 2 and 3 until you have a list of all AVHDX files with their respective parent AVHDX files
  5. Beginning from newest AVHDX file (only AVHDX file with no child file), run following command:
    • Merge-VHD -Path ‘<path to AVHDX>’ -DestinationPath ‘<path to parent AVHDX’
  6. Repeat step 5 on each AVHDX, always starting with newest available file
  7. Once all AVHDX files are consolidated, merge last AVHDX with main VHDX file:
    • Merge-VHD -Path ‘<path to AVHDX>’ -DestinationPath ‘<path to main VHDX disk’

As far as I am aware, the internet calls this a manual method to merge the AVHD/X into VHD/X. Feel free to drop a comment in the comment section below. Thank you πŸ™‚

Comments

  1. It抯 really a great and helpful piece of information. I am happy that you simply shared this useful info with us. Please stay us informed like this. Thanks for sharing.

  2. Thanks for the sensible critique. Me and my neighbor were just preparing to do some research on this. We got a grab a book from our area library but I think I learned more clear from this post. I’m very glad to see such magnificent information being shared freely out there.

Leave a Reply

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

PHP Code Snippets Powered By : XYZScripts.com