With the introduction of Virtual PC 2004 Service Pack 1, Microsoft have introduced a "pre-compactor" tool which runs on Windows guests and carries out the zeroing out of unused sectors for you, making the process much simpler.
Steps 1 through 6 are to be completed inside the guest machine. Steps 7 to 14. are to be completed on the host machine, via the virtual PC console. Take a backup of the guest machine BEFORE starting any work of this kind!
- Log on to the Guest machine session you wish to compact and run a defrag before you start.
- Load the Pre-compactor
- Go to CD Menu, then Capture ISO Image.
- Browse to the Virtual Disk Pre-compactor CD image 'Virtual Disk Precompactor.iso'. (The default location is C:\program files\Microsoft Virtual PC\Virtual Machine Additions). Select it, Click OPEN.
- If Autoplay is enabled in the guest, the pre-compactor will autorun.
- (If Autorun isn't enabled, browse to the CD in the guest and double-click 'precompact.exe to run it)
- A dialogue will appear stating "Would you like to prepare the Virtual hard disk(s) for compaction?" - answer YES.
- Wait for the pre-compactor to do its thing in the Guest.
- When the pre-compactor completes it will tell you to shut down the virtual machine and use the virtual disk wizard to complete the disk compacting. Follow its advice by shutting down the guest machine completely.
- From the File menu on the virtual pc console select 'Virtual Disk Wizard'
- Click NEXT at the Wizard's welcome screen.
- Select 'Edit an existing virtual disk', then click NEXT.
- Browse to find the virtual hard disk (.vhd file) you pre-compacted in steps 1-6. Select it and click OPEN.
- Click NEXT
- Select 'Compact it' under the list of options for the virtual hard disk. Then click NEXT.
You can either replace the existing file or create a new .vhd file. Up to you. Make your choice, specifying a new name & location if you want a new .vhd file. Then click NEXT.
- You should be at the final screen in the wizard. Click BACK to go back and review your selections or Finish to start compacting your virtual hard disk.