Select Page
This entry has been published on 2016-09-03 and may be out of date.

Last Updated on 2016-09-03.

[:en]It happens that VHD files get quite large, even it they are dynamically sized, for various reasons (growing logfiles, user mistakes or other scenarios where large files are deleted afterwards).

The dynamic VHD grows automatically, but does never shrink by itself. The VHD size on the hypervisor stays large by default, but you can manually let it shrink again, even if the guest’s HDD format is not NTFS.

First, make sure that the VHD is of type “dynamic” and the guest OS shows free space. The whole procedure would not make much sense otherwise.

For Linux machines (e.g. with EXT2/3/4 file system), do the following:

  1. Download SystemRescueCd ISO file
  2. Boot your VM from this image file
  3. Execute “zerofree /dev/sda1 -v”. (sda1 should be your VHD by default, -v shows the progress in percent)
  4. When finished, shut down the system and disconnect the ISO.
  5. Like with Windows guest VHDs, compress your VHD now via common Hyper-V harddisk compression wizard.
  6. Your VHD should be shrinked now.

 [:]