To compact a dynamically expanding Linux virtual hard disk you will first need to zerofill the unused area. This is done by using the dd(data dump) tool.

This will create a file filled with NULL chars and then remove it.

When it is finished, shut down the machine and compact the disk.

You can compact the VHD by following the “2. Compact VHD” – step here