New tool for precompacting virtual hard disks

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.

I know I’m a little late here, but it hit me today while I was replying to a Virtual Server newsgroup post: Will we see the "pre-compactor" released for Virtual Server as well (or better yet, just as a download at Microsoft.com)? I know that the VS Administrator’s guide gives info on compacting (and I quote, "Use a non-Microsoft disk utility program to "zero out" deleted data, which overwrites the data with zeros.",) but the same way that having the ability to zero and compact is a very welcome addition to Virtual PC, it would also be welcomed for Virtual Server.