Compacting Virtual Hard Disks with Hyper-V

Rate This
  • Comments 3

When you choose to compact a virtual hard disk with Hyper-V a very interesting process is used.  The virtual hard disk is actually connected to the parent partition (but it is not mounted).  Windows then inspects the virtual hard disk.  If the virtual hard disk is NTFS formatted, the NTFS data structures are analyzed to determine how to compact the virtual hard disk.  If the virtual hard disk is not NTFS formatted it is analyzed as a raw device and zeroed out blocks are compacted.

This means that if you have a NTFS formatted virtual hard disk you do not need to prepare the virtual hard disk for compaction.  If you have a virtual hard disk that is formatted with a different file system you will still need to use an application to zero out free space on the virtual hard disk before attempting to compact it.


Leave a Comment
  • Please add 5 and 2 and type the answer here:
  • Post
  • Oh wow, this is so cool.

    Any chances of this feature making its way into a service pack for VPC 2007, or a future version.

    Any chances of other OS vendors being able to extend this so that they can implement a plug in to similarly benefit other OSes? I think the Linux community would be very interested in doing so.

    I know you don't talk about future functionality, but how about passing this on as a suggestion?

  • Cool, but do you need to defrag NTFS drives to get maximum space back or will the shrink move the files to the start of the drive?


  • Hi,

    without Zero Out it doesn't work on NTFS vhd with Window Server 2008 SP2. How ever Zero Out with Sdelete increases first the vhd, before it can be compacted afterwards. This is really a challenge if the disk space is already tight.

    Any recommendation how to tackle this?



Page 1 of 1 (3 items)

Compacting Virtual Hard Disks with Hyper-V