Skip to content

Compacting a Windows 7 VHDX

 

In a recent lab test I needed a windows 7 VM, but noticed that the VHDX was much larger than the actual disk usage in the VM. With SSD storage being at a premium I wanted to compress the VHDX, but it proved to be a bit tricky

clip_image001

clip_image002

The on machine usage:

clip_image003

I should be able to edit disk and compress in Hyper-V

clip_image004

clip_image005

But this had no effect,

clip_image001[1]

I had to mount the VHDX in windows on the server

clip_image006

Run Optimise on both the disks while they were mounted (right click on the two mounted drives

clip_image007

clip_image008

The dismount/eject the drives:

Then Optimise them via PowerShell:

PS C:\Users\Administrator> Optimize-VHD -Path U:\Win7-1\Win7-1.vhdx -Mode Quick

This brought the VHDX down to a more respectable 25GB

clip_image009

This thread really helped:

https://social.technet.microsoft.com/Forums/windowsserver/en-US/b57c87f9-79b2-46e9-a471-005b45246c8c/vhd-and-vhdx-wont-compact?forum=winserverhyperv

Particularly twgage’s answer, thanks

Published inHyper-v

Be First to Comment

Leave a Reply

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