Dec 13 2014

Hyper-v vhd Virtual Disk Does Not Reduce

Published by at 12:24 am under Virtualization

You’ve freed up a lot of space on your hyper-v virtual machine and tried to compact the vhd file but no luck, it doesn’t shrink as much as it should.
Here are a few things I tested:
Defrag, shrink volume from the VM disk manager, Defrag adding the vhd on another VM as a secondary drive so system files can be defragmented, generate a new vhd from the original copy, nothing seems to be working!
The problem is NTFS does not clean space freed up by removed files, and that space isn’t released while compacting.
In order to get all the free space released when compacting, you can use sdelete from the excellent Microsoft sysinternals tools to replace freed bits by zero
Download sdelete and run if you want to clean the VM C: drive

sdelete -z C:


You can now successfully compact the vhd file.

No responses yet

Trackback URI | Comments RSS

Leave a Reply