Compacting Hyper V Vhdx disk

Compacting Vhdx
Power off the VM
In Computer Management/Disk Management, right-click and choose Attach VHD
Right-click on the partition and choose Shrink Volume
Right-clicked on the Disk (not any partition on the disk) and chose Detach VHD.
Then I did these steps:
diskpart
select vdisk file=”D:\Virtual Machines\Vm2\Vm2_Disk1.vhdx”
attach vdisk readonly
compact vdisk
detach vdisk
exit
Shrunk!

Leave a Reply