Kurt's profileKurt Shintaku's BlogBlogListsSkyDrive Tools Help

Blog


    May 14

    HOWTO: Compress Virtual PC virtual hard disks (.VHDs)

    If you use Virtual PC 2007 you know that the virtual hard drive files (.VHDs) can grow to extremely large sizes.  Part of this is because the .VHD files dynamically expand when software is installed in the .VHD however after the installation, the original setup files are deleted and no longer take up space in the .VHD, however the .VHD does not correspondingly dynamically shrink in size.  Once a .VHD file expands - it doesn't shrink. 

    EXAMPLE:  If the installation of a product like Microsoft Office uses 500MB to expand it's setup files and consumes 340MB in the \Program Files directory the .VHD file expands accordingly.  When the 500MB of setup files are subsequently deleted after the installation has completed, the .VHD file doesn't shrink accordingly.

    Normally, people don't care about file size bloat that much however when you're using Virtual PC .VHDs you may be talking about 3-4GB of wasted storage or more.  So the question is, "How do I shrink the size of a .VHD when I know it's inflated unnecessarily?" 

    Here's how to do it:

    1. 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.
    2. 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.
    3. 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
    4. 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
    5. Shutdown the Virtual PC
    6. 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.
    7. Compact the .VHD
      Select the "Compact" option then select "Replacing the original file".  This will take a few minutes.

    When this process finishes, you should have a .VHD file with a much smaller size.

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.
    Kurt Shintaku has turned off comments on this page.

    Trackbacks

    Weblogs that reference this entry
    • None