I’m currently running Virtual PC 2007 on one of my systems in order to run a virtual machine.
I noticed that the VHD file was 28.4 GB in size, yet the virtual hard drive itself seemed to be much smaller when looking at the used space from within the virtual machine.
I did some digging and found that VHD files can bloat in size after some use.
After running through the steps below, my VHD file reduced from a size of 28.4 GB down to 17.1 GB (almost a 40% reduction).
Here are the steps I went though:
- Clear out the machine of filler
I recommend installing CCLEANER.EXE from http://ccleaner.com which deletes all temporary files from the Windows installation, Internet Explorer cache, the Recycle Bin, and any number of other “garbage”/”temp” directories in the VPC.
- Disable hibernation
If you have hiberation turned on, there’s a colossal sized file called hiberfil.sys in the root of the .VHD. Go into Power options in Control Panel and disable hiberation to get rid of this file.
- Defragment the hard disk
From within the virtual machine, right-click on the hard disk, choose Properties, then the Tools tab, and then Defragment Now.
- Capture the Virtual Disk Precompactor .ISO
In the menu of Virtual PC windows for your machine, capture the Virtual Disk Precompactor .ISO file which is located at:
c:\program files\microsoft virtual pc\virtual machine additions\virtual disk precompactor.iso
- Run the Precompactor
Go to My Computer and double click on the mounted disk. It will begin to run the precompactor software which will essentially zero out all the free space on the disk, making it available for elimination from the file by the Virtual Disk Wizard, which we will use later. This process may take upwards of 15 minutes
- Shutdown the Virtual PC
- Run the VPC2007 Virtual Disk Wizard
From the Virtual PC console, click File-Virtual Disk Wizard and “Edit an existing virtual disk”. It will ask you to identify the .VHD file to reduce in size – select it.
- Compact the .VHD
Select the ”Compact” option then select “Replacing the original file”. This will take a few minutes.