Background on Fragmentation: The computer writes information disk into concentric circles on the hard drive, called tracks. Each track is divided into small sections, called sectors. When a file is written, the computer puts it into the first open sector. If the file is bigger than the sector, it gets written across multiple sectors. When a file is deleted, that sector frees up and is listed as open. The sector isn't physically deleted - instead, it's marked as clear, and eventually it'll be overwritten by new data. That's why recovery software can retrieve deleted files off a computer, even if it's been deleted, recycle bin is empty, etc. In Virtual PC, this can make a .VHD file larger than the amount of data it actually contains, because some of its space is taken up by open sectors that haven't yet been overwritten. Virtual PC has a wizard that will compact .VHD files and free up space. Fragmentation occurs when a files is written into open sectors that aren't physically continuous on the disk, which happens over time as scattered sectors are marked as free. Defragging moves the files around, lining their individual sectors up together physically, so the magnetic read/write head in the drive doesn't have to move so much. With Virtual PC, we experience two levels of fragmentation: files inside the VPC are fragmented across the virtual drive, and the .VHD file itself can get fragmented, especially if you've loaded then deleted a lot of VHDs or other large files. A lot of the performance issues we can experience with Virtual PC are the result of drive fragmentation. These steps will defrag your Virtual PC hard drive, compress it to a smaller file size, and optimize its location on the host drive.
How to Defrag:
1. Defrag your Virtual drive.
a. Launch the Virtual Machine, log in as an administrator
b. Remove any Installation temporary folders or un-needed folders
c. Empty the Recycle Bin
d. Go to Start/Programs/Accessories/System Tools and run Disk Defrag
e. This can take 10 minutes to 30 minutes to run
f. Do this at least 3 teams, until it defrags quickly
2. "Zero out" your
3. Compact your Virtual Drive
a. Shut down any running Virtual PCs
b. Under the Virtual PC console, select “File” then “Virtual Disk Wizard”
c. Select “Examine or Modify existing disk image”
d. Select the disk image file you wish to compact
e. Select “Compact the disk image”
f. Select “Use original file” (or a separate file if you require)
g. Finishing the Wizard will compact the file. This may take a long time
4. Defrag your host drive (the one the .VHD files are sitting on)
a. Shut down all applications on your laptop.
b. On your laptop go to Start/Programs/Accessories/System Tools and run Disk Defrag
c. Do this at least 3 times as well - until it defrags quickly
Note: The host defrag step takes the longest - it can take 30 minutes to several hours to run. You'll need at least 15% of the disk free to run the defrag optimally. If you have really large files (like VHDs) they may not defrag - it'll tell you in the log report when it's done. If that happens, move them off your main drive to a backup location, run step 5 again, then move them back onto your drive.
Tip: If you zip up VHDs you won't use for a while, you can compress them to about 50% their original size. If you're working with standard images, just delete the VHDs and restore them from the TAN