Piriform
Defraggler

How Windows stores files and how Defraggler works

(This is a high-level discussion to help you understand the concepts behind Defraggler's operation. For more information on Windows' filesystem, see http://en.wikipedia.org/wiki/File_system#File_systems_under_Microsoft_Windows.)

How Windows stores files

Hard drives are divided into sections, or clusters, which are the smallest unit of hard space that can be allocated to a file. A file can live in multiple clusters scattered across the hard drive. The Master File Table (MFT) tracks the file's location and which clusters it uses.

When Windows deletes a file, it simply removes the index entry from the MFT, and then tells the MFT that the clusters the file occupied are free for reuse.

When Windows writes a new file, it checks to see which clusters are free, splits the file up among them, writes the file to those clusters, and then adds the index entry in the MFT with the file properties and the clusters where it is located.

Since files of different sizes are constantly being added and deleted, files end up getting scattered across clusters all over the hard drive. This is inefficient, because when Windows requests a fragmented file, the hard drive has to move to various sections of the disk to retrieve it. If only the file clusters were right next to each other...and that's what Defraggler does.

What Defraggler does

Defraggler scans the hard drive for folders and files that are scattered in non-contiguous clusters (clusters that aren't right next to each other). Using a single-pass algorithm, it designs an optimum layout for these files so that Windows will spend the least amount of time retrieving them in the future. Finally, Defraggler moves the files into this optimum pattern.

Defraggler and the Master File Table (MFT)

As noted above, the MFT stores the locations of files on the hard drive. The MFT is represented as a file (called $MFT), but it cannot be defragmented in the same way as other files. The location of the MFT's first fragment is fixed. Defraggler can only gather up the other fragments of the $MFT file and append them to that first fixed fragment.