Compacting your dynamically expanding virtual hard disks (VHDs) reduces the amount of disk space they use. Preparing a disk and compacting it is covered in the Virtual Server 2005 Administrator’s Guide, so I won’t go into it here. What’s new is this: you used to have to use a third-party tool to zero out available blank space on the VHD before compacting it. Now you can use a tool that’s included with Virtual PC 2004 SP1 — the Virtual Disk Precompactor.
If you have Virtual PC 2004, you can simply install SP1 to get this utility.* Otherwise, you’ll need to download the trial version of Virtual PC 2004, and then install SP1. (If you try to install it on your Windows Server 2003 machine, you’ll get a warning that it isn’t a supported OS. You can ignore the warning.)
To use Virtual Disk Precompactor, you must first capture Virtual Disk Precompactor.iso, which is installed with Virtual PC 2004 SP1. For instructions on capturing media, see “Add or remove a CD or DVD drive” in the Virtual Server 2005 Administrator’s Guide. Virtual Disk Precompactor.iso is located in %ProgramFiles%\Microsoft Virtual PC\Virtual Machine Additions\.
After you capture Virtual Disk Precompactor.iso, you can run Virtual Disk Precompactor from the command line by navigating to the CD drive of the virtual machine and typing Precompact. The available parameters are:
-Help – Displays help for the precompactor.
-Silent – Runs the precompactor in unattended mode.
-SetDisks – Specifies the disks to be precompacted. If this parameter isn’t specified, then all virtual hard disks for this virtual machine are compacted.
Example: Precompact -Silent -SetDisks:CDE
Note that you can only compact dynamically expanding virtual hard disks. To compact fixed-size VHDs, you can convert them to dynamically expanding VHDs, compact them, and then convert them back to fixed size.
* As announced in my posting of January 12, 2005 (http://blogs.msdn.com/megand/archive/2005/01/12/351756.aspx), this tool also will be available in Virtual Server 2005 Service Pack 1.