Microsoft Virtual PC uses virtual machine hard drive images as disks. These VHD files are typically dynamic in size, they grow as necessary. And I had one grow on me yesterday to over 40GB in size! Microsoft provides a Virtual Disk Wizard which can be used to compact virtual disks (when the virtual machine is not running). But, running it barely reduced the size at all. The problem? The wizard looks for space that has been zeroed out, so that must be done before running the wizard. It would have been nice if the wizard had spelled this out, and also provided instructions on how to do this. But it doesn’t (which is odd, as Microsoft actually provides a mechanism to do this)! So, in case anyone else runs into this one, this is what you need to do:

  1. Power up the virtual machine.
  2. Clean up the drive (empty the Recycle Bin, get rid of temporary files, and so on).
  3. You may even want to defrag the drive.
  4. Then, locate a file named virtual disk precompactor.iso (it should be in c:program filesmicrosoft virtual pcvirtual machine additions), and capture the ISO image (right-click on the CCD icon to do this). This will start the precompactor program which zeros out unused space.
  5. Then shut down the virtual machine.
  6. And finally, run the Virtual Disk Wizard which should shrink the virtual disk, removing all zeroed out space.

My virtual disk is now down to a more manageable 6GB, whew!

9 thoughts

  1. You can even decrease the size by disabling the page-file before running defrag (this will need another reboot to get the setting inot effect) and yes this will slow down the system..
    I use this to prepare sysprep VHD images..

  2. Hello Ben,
    i found you information about "shrinking a VPC-File". I read you instruction, but what did you mean with step 4 "locate the file and capture the iso -file to what do this? do you have more tips for using the vpc?
    Thanks for your support and regards from the north of germany (a little village between Bremen and Hamburg).
    Regards
    Carsten

  3. Carsten, there is a file named "virtual disk precompactor.iso" that is installed along with Virtual PC. Locate it. Then in the virtual machine map the CD to that file to use the CD image.
    — Ben

  4. I was confused about step 4 too. With the Virtual PC running, you’ll have a "CD" menu option on the Virtual PC’s main menu. Choose that option, and it will let you capture the file as a CD image. Once you choose that option, you’ll be able to browse for that ISO file and it will launch the Pre-Compactor

  5. Just in response to your comment: "It would have been nice if the wizard had spelled this out, and also provided instructions on how to do this. But it doesn’t (which is odd, as Microsoft actually provides a mechanism to do this)! "
    If you actually read the dialog box in the Virtual Disk Wizard, the first sentence after choosing to compact your drive is: "Before you compact this virtual hard disk, you must zero out free space on it, by using Precompactor"

  6. As per comment by Rob
    >>With the Virtual PC running, you’ll have a "CD" menu option on the Virtual PC’s main menu.
    There is no such CD menu on Win7 VPC. How to do this step in Win7 VPC ? (not in the standalone product VPC).

  7. Here’s how I do it:
    1) Make sure the VHD is shutdown (status should be Powered down)
    2) In the Virtual Machines folder, right-click the Virtual Machine
    3) Click Settings on the menu
    4) Select the HD in question and click Modify
    5) Select the option to Compact

Leave a Reply