Minimizing Your Virtual PC Hard Drive

Just installed Microsoft Visual Studio 2010 Beta 2 in a virtual PC (Microsoft Virtual PC 2007). It is kinda slow, but it works.

In the process I created two “baseline” images – a “pure” Windows XP install, and the original VS 2010 just after the installation. What I found that the virtual hard drive size may increase considerably as you start using the system. Here’s the algorithm I used to minimize the size of the “baseline” file:

  1. Shut down the virtual PC
  2. Copy virtual hard drive to another file
  3. Edit your virtual PC settings to mount the copy as a second hard drive
  4. Run the virtual PC.
  5. Remove pagefile.sys from the copy. Make sure it does not end up in the recycle bin!
  6. Defragment the copy using Dave Whitney’s defragger (google it if the link is broken).
  7. Using CD menu of the Virtual PC mount “Virtual Disk Precompactor.iso” from “C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\” on your host system.
  8. The precompactor application by default zeroes out free space on all mounted hard disks. Stop it and use command line options to precompact only the second virtual hard disk.
  9. Shut down your virtual PC.
  10. From Virtual PC Console choose VHD wizard and compact the baseline disk.

These operations may take a while, but it is well worth it – I went from 4+GB image to 1.8GB.

Leave a Reply

Your email address will not be published. Required fields are marked *