Efficient Method of Compressing Virtual Hard Disk (.vhd) Files
While sitting with my friend Adam yesterday he asked to see something on Windows XP, so I booted my laptop and started up Virtual PC 2007. As I navigated to find what he wanted to see he told me that he was upset with Virtual PC, which he uses frequently, because he has had a virtual machine for over a year and the virtual hard disk (.vhd) file has gotten to be quite large (30 gigabytes). He told me that he used the compression tool included with Virtual PC 2007, but that after running for thirty minutes the results were nominal at best, where the .vhd file was still nearly 30 gigabytes, whereas the data on the drive did not exceed ten or eleven gigabytes.
We have to remember that our virtual machines are completely autonomous PCs with no exceptions (except that they require less dusting). However if it has to be done to a physical PC then it also likely has to be done to a virtual PC... that includes anti-virus, patch management, and yes, defragmenting your disks.
The way file systems work is similar to the way I organize my desk: when I only have a couple of things on it, they are spread out, and when I have a lot of stuff on it everything is packed in together. When I then take a few things off it (that does not happen often) a bird's eye view will show things in all corners of the desk, even though they are spread out. Tidying up changes that. Think of defragmenting your hard disk like tidying up your file server... and if you have ever looked at a map of a frequently used hard drive you will notice that there are bits stored at the beginning and bits stored at the end... even if there are bunches of empty blocks in the middle. Defragmenting the disk will move everything to the beginning (or as near to it as things get on a used hard drive).
The way the Virtual PC virtual hard disk conversion tool works is it looks at the virtual disk, and removes from the end what it can. It does not first go ahead and tidy up before doing so. By booting the guest OS first and defragmenting the drive you will give the tool much more to work with, and it will in turn offer much better results.
Good luck!