-- Ben Armstrong, Virtualization Program Manager
Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).
If you have installed Linux (or a *BSD variant) inside of a virtual machine under Virtual PC or Virtual Server - you will probably want to compress the virtual hard disk after a while, to reclaim any unused space on the virtual hard disk. In order to do this you will need to 'zero-out' the virtual hard disk first. Now - we provide a handy tool to do this under Windows - but under Linux all you need to do is to run the following command:
cat /dev/zero > zero.dat ; sync ; sleep 1 ; sync ; rm zero.dat
This will create a very large temporary file that has nothing but binary zeros in it, synchronize the hard disk and delete the temporary. Once this has completed you can shutdown the virtual machine and compact the virtual hard disk by editing it with the virtual hard disk wizard. Using this command I was able to reduce my SuSE virtual machine from 6.9GB to 4.12GB in size.
Cheers,Ben
This didn't have quite the desired effect for me either. Linux VM says it's using 40G, VHD was 72G, compacting had no effect. Running the suggested command increased the VHD to 101G, compacting it reduced it to 93G :(