What does the vhd pre-compactor do?
Files are represented on disk by a sequence of blocks. The operating system maintains a list of free blocks and used blocks. When files are created by a program, the operating system takes some of the free blocks, marks them as used and attaches them to the file. Similarly when the file is deleted the blocks as part of the file are put back on the free block list.
However the deleted blocks are not zero’ed out. So consider a virtual image which at its peak had 3GB of used blocks, but since then a lot of files have been deleted and is currently using only 1GB. There are 2GB of free blocks on the system, but these blocks are not necessarily zero, they may contain the contents of some files which have been deleted.
The pre-compactor zeros out the deleted blocks. It does this by creating a large file and writing zeros to it. The operating system keeps giving it all the free blocks and the pre-compactor just zero’s them out.
Then the compact tool can collapse these zero blocks and realize some savings. Ideally one should run defrag on the disk before running the pre-compactor (see article)