Compacting Virtual Hard Disks


My little USB hard drive recently ran into a space constraint issue because of the footprint of my Virtual Machines I keep stored there.  So I went about attempting to reclaim some space by collapsing my Virtual Machines expanding disks and freeing space that they were not using.

A note about my configuration:

I use Virtual PC (2007 Beta) as well as Virtual Server 2005 on Vista RC1.  I use Virtual PC when I don't have the requirement of having 2 virtual machines running at the same time.  When I have to simulate a domain scenario, etc. I then fire up the VPC's in Virtual Server.  So far I've had pretty good luck using t hem interchangeably between VS and VPC. 

An note about differencing disks:

I'm not Virtualization expert, however, I use differencing disks to save space whenever possible.  The guidance I've found is that you can't collapse virtual machine differencing disks.  You can only merge them back into their base image (thereby breaking a chain of dependencies that other machines will have on this vhd).

The guidance to reclaiming space from dynamically expanding (non-differencing) disks is as follows for VPC and VS 2005:

  1. Open the virtual machine and defragment the virtual machine's hard drive
  2. Mount an ISO within the virtual machine found in the utility directory of the VPC install called the Microsoft Virtual Disk Pre-Compactor found at C:\Program files\Microsoft Virtual PC\Virtual Machine Additions\Virtual Disk Precompactor.iso. 
  3. Shut down the virtual machine.  Here is where the paths differ between VPC and Virtual Server 2005
    • VPC
      • In the Virtual PC Console, run the Virtual Disk Wizard and choose to edit an existing virtual disk and browse to the hard disk. 
      • Select compact it and replace the original file
    • Virtual Server
      • Choose to inspect the Virtual Hard disk and select the disk from the drop down
      • Select the compact operation
  4. Note that the operation makes a copy of the disk.  Also the reason to run the utility that pre-compacts the drive is to zero out all the unused bytes on the vhd.  Otherwise the compact will think that they are still in use.
Comments (1)
  1. brandontyler says:

    I found the same thing.  Virtual PC would not let me compact my disk that was a differencing disk.  When I choose the option to edit the disk all it would let me do is merge back with the parent.  Why can’t you compress a differencing disk?

Comments are closed.

Skip to main content