Optimizing Virtual PC 2004 Hard Disks

If you use Virtual PC 2004 frequently, you are going to notice that the virtual hard disks (.VHD) files growth a lot, as files are saved within the VPC environment, because dynamic VHDs will expand to meet the need of space.

But the VHD do not return the space to the host hard drive once you clean space on it.

For doing so you need to do a set of manual steps:

Steps on the Host OS:

  • Empty the recycle bin on the drive where the VHD is located
  • If the 'hiberfil.sys' file is located in the same drive that the VHD, then disable hibernation
  • Defragment the drive where the VHD is located

Steps on the Virtual Machine OS:

  • Shut down the VPC (do not save state)
  • Install VPC SP1
  • Restart the VPC once SP1 is applied
  • Log on as an Administrator
  • Remove the paging file Clear the temp directory

Defragment the drive Zero the free space on the disk:

  • Capture Virtual Disk Precompactor image, its located at C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\Virtual Disk Precompactor.iso
  • Execute Precompact.exe located on the drive mounted
  • Shut down the VPC (do not save state)

Compress the virtual hard disk:

  • Open Virtual PC Console go to File, Virtual Disk Wizard
  • Select Edit an existing virtual disk
  • Browse to the location and file name of the VHD file
  • Ensure that the Compact option is selected
  • On the Virtual Hard Disk Compaction page, select Replacing the original file
  • Once the disk is compacted, restart the VPC
  • Add the paging file again

Pablo

This article is part of the GWB Archives. Original Author: Pablo Galiano

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.