MS Virtual PC - Compact Dynamic Virtual Hard Disk For Linux Guest OS
If you are using Microsoft Virtual PC with dynamic virtual hard disk, you will realize that the size of the dynamic hard disk grow over time and it will not shrink.
MS Virtual PC provide a function to compact hardisk
But prior to use that function, you have to prepare the disk for compaction. Their preparation is simply mean zeroing your hard disk. MS Virtual PC can only reclaim zero-ed hard disk space.
For Linux, do the following
1. Start up your Linux virtual machine
2. At the console in any directory level, type
cat /dev/zero > zero.data
This will eventually fill up your virtual hard disk with 0 in zero.data. This will take some time depends on the size of your hard disk.
3. When it is done, type the following commands
sync; sleep 30;sync
This is to make sure the data is written to disk
4. Then, type
This is to remove the zero file. By doing the above operation, it filled the virtual disk with zero data.
5. Shut down the Linux Virtual Machine and run the Compact Tools at MS Virtual PC
The above helps me to shrink a 20GB virtual hard disk to 11GB virtual hard disk
For information how to compact a dynamic hard disk for Window Guest OS, see http://support.microsoft.com/kb/824517
For information on wiping hard disk, see http://superuser.com/questions/19326/how-to-wipe-free-disk-space-in-linux