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:
- 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.
- 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.

- If the mounted disk does not autoplay, go to My Computer and double click on the mounted disk.

- 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.
- Shut down the Virtual PC.
- From the Virtual PC console , click File/Virtual Disk Wizard.

- Choose “Edit an existing virtual disk”. Browse to the .vhd file that you want to shrink.
- Select “Compact it”.
- If you’re paranoid, you can select a different file name for the compacted file. I selected “Replacing the original file”
Stay Chief,
“Our chief want is someone who will inspire us to be what we know we could be.”
-Ralph Waldo Emerson
Advertisement