How Defragmenters Work
All defragmenters start by making a map of your logical hard drive and seeing what clusters from which files are placed where. The next step is to shift clusters around to put the clusters belonging to a particular file in order and next to each other on the logical disk.
On a badly fragmented disk, the process is akin to one of those pocket puzzles where you slide squares around in a frame to get them in the right order. A cluster may have to be placed in several intermediate locations before it ends up where it is supposed to go.
The intelligence comes in figuring out how to move the clusters and get the best results in the fastest time while leaving the disk in the best shape.
Just what constitutes the "best shape" for a defragmented hard disk is one of the places where disk defragmenters differ strongly. The most obvious method of defragmenting a disk would be to gather all the unused space into a single large area. That might be fine for a freshly defragmented disk, but it quickly becomes inefficient if as the disk continues in use, because there is no contiguous free space for files to grow into.
"Having all the free space in one line and all the files in one line might not make sense," says Paul Shomo, a technical spokesperson for Diskeeper Corp. Instead, most modern defragmenters attempt to position the files and free space on the logical disk in the most useful manner. For example, Diskeeper attempts to estimate how much the Master File Table (MFT) is likely to grow and allocates free space for the growth in front of the MFT.
PerfectDisk looks at the files that haven't changed in the last 60 days, and places them all together on the disk after defragmentation. If the files don't change by the next defragmentation run, that section of the disk doesn't have to be changed, which speeds up future defragmentation. PerfectDisk also attempts to put the files that change frequently next to free disk space.
And, of course, the defragmenter has to do all this safely. Losing a cluster while defragmenting a logical disk can make an file unreadable. It might even corrupt the entire disk, if the problem occurs in a critical area like the Master File Table (MFT). Disk defragmenters take great and elaborate care to make sure nothing is lost in the process.