Friday, August 29, 2008

Compacting Virtual PC 2007 Disk

I have been using Virtual PC off and on since the 2004 iteration. One area that I have come across is shrinking the disk. I started to read through the manual/help file provided and found this:

(Search 'Using Virtual Disk Precompactor' in the help file for the textual version).

Let's get started and see what happens:

Things needed:
  • Time and patience
  • Make sure you have the Virtual Disk Precompactor.iso for Windows guests. (Linux guest compacting will be posted later).

Some quick tidbits and begin:

  • My virtual disk is set to 64GB logical partition within the guest.
  • My host system shows the "vhd" at 21GB right now.
  • Empty 'Recycle Bin'.
  • Run disk clean up on my logical drive.
  • Run your favorite defrag utility on the drive within the guest.
  • Capture the Virtual Disk Precompactor.iso file from PC\\Program Files\Microsoft VirtualVirtual Machine Additions\ (your installation directory will vary)
  • When the CD mounts, you will be prompted if you want to automatically start the program.
  • If you have more than one disk in the guest, choose no so you can select the disk to precompact. This is done with the '-setdisks' command option. If you don't do this AND you have multiple disks, running the program will compact ALL of the disks.
  • Go get some coffee, a beer, soda, can of tuna...this may take awhile. I timed my run:
Start time: 5:42 PM
4 bars o' progress: 5:53 PM
End time: 6:19 PM

Back to bullets...
  • Shut down the guest
  • Go through the Virtual Disk Manager in the Virtual PC 2007 Console
Start time: 6:19 PM
4 bars o' progress: 6:28 PM
10 bars o' progress: 6:38 PM

At this point, I realized that running the compact and having the disk retain the same name is going to create a bottleneck. So I changed the destination to another drive - completely separate from the source drive where the original VHD lives.

I canceled and then restarted the compact. Note, you are going to need a ton of extra disk space on the destination drive if you use this method.

Start time: 6:41 PM
5 bars: 6:50 PM
10 bars: 6:55 PM
15 bars: 7:02 PM
20 bars: 7:11 PM
End time: 7:26 PM

Without the information on my computer, applications or services I have running, and the hardware from one disk to another, the times mentioned above are only to illustrate how long these steps may take.

The destination disk, for me, ended at 11.8GB. That's a 43% reduction in the disk sized used.

From a virtual machine perspective, a couple of items I usually will run with:
  • Turn off 'System Restore'. I see no real need for this in a virtual machine
  • Turn off 'Virtual Memory'. Swapping to a virtual disk causes a waste of IO between the host and guest.
  • Turn off 'Automatic Updates'. I run manual updates and select only those I want/need.
Obviously, if you use these functions specifically in your virtualization purposes, use them.

Good luck.

Using Virtual Disk Precompactor