If there is empty space inside the disk, and the virtual disk is much bigger, you can shrink the virtual disk (vhdx).
Run this command within the virtual machine to zero out the empty blocks (takes 1-2 minutes for a 300GB drive):
Optimize-Volume -DriveLetter C -ReTrim -SlabConsolidate -Verbose
Then shutdown the virtual machine and run this command on the Hyper-V host (takes 5-10 minutes for a 300GB drive):
Optimize-VHD -Path "D:\Hyper-V\Virtual Hard Disks\VirtualDisk.vhdx" -Mode Full -Verbose
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article