Shrink VHD Files in Microsoft Virtual PC 2007

November 28, 2008

I recently made the mistake on a Virtual PC of extracting a very large compressed file on the local hard drive of the Virtual Machine.  I had a Dynamically Expanding disk which expanded to an enormous size.  It nearly filled the local hard drive of my host machine.  Now when I removed the files after I was finished with them, the file did not shrink back down to reflect this.  This results in wasted hard drive space on the host PC as well as more resources being used when you are running the VPC.

Here are the steps I took to shrink it back down:

  1. I read some articles recommending to empty the recycle bin, delete temp files, disable hibernation.  This is good advice (emtying the recycle bin espessially), but is really only useful if you temporarily want to shrink the vhd as much as possible (perhaps in preparation to do a file transfer, or fit it on a DVD).  If you do this clean up, eventually the vhd will expand again as the recycle bin and temp files build up again.  I also want hibernation enabled so I didn’t disable it.  My goal was to recover the space I lost when I expanded the huge archive.  Your goal may be different, so you may want to take the steps mentioned above.
  2. The Virtual Disk Precompactor is the prep utility which releases free space making it available for elimination from the file by the VIrtual Disk Wizard.  On the Virtual PC Menu go to CD/Capture ISO Image, and Browse to C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\Virtual Disk Precompactor.iso.
    Capture ISO Image
  3. If the mounted disk does not autoplay, go to My Computer and double click on the mounted disk.
    Run the Precompactor
  4. You should be prompted with “Would you like to prepare the virtual disk(s) for compaction?”.  Click Yes.  The process will run for several minutes.  You will be notified upon completion.
  5. Shut down the Virtual PC.
  6. From the Virtual PC console , click File/Virtual Disk Wizard.
    Virtual Disk Wizard
  7. Choose “Edit an existing virtual disk”.  Browse to the .vhd file that you want to shrink.
  8. Select “Compact it”.
  9. If you’re paranoid, you can select a different file name for the compacted file.  I selected “Replacing the original file”

Stay Chief,

Chief

“Our chief want is someone who will inspire us to be what we know we could be.”
-Ralph Waldo Emerson

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.