next up previous contents
Next: Third Party Disk Defragmentation Up: Disk Defragmenter Previous: Windows 98

Windows NT

Microsoft included five undocumented and unsupported functions in Windows NT 4.0 for doing disk defragmentation. The functions were added as a result of bad experiences with third party defragmenters written for Windows NT 3.5 and 3.51 (explained in section 5.4.2 on page [*]). [Rus97]

These functions are:

Mapping a drive requires three steps: [Rus97]

1.
Get map of free clusters with GetVolumeBitmap [Rus97]
2.
enumerate all files on the drive and obtain file cluster maps using the GetRetrievalPointers or the ReadMFTRecord functions [Rus97]
3.
display file mappings [Rus97]

In order to catch changes, defragmenters must repeat all three steps for each file it processes. Clusters are moved with MoveFile. [Rus97]

If there are any clusters in use but not allocated to a file, these clusters are system metadata, directories, or files opened exclusively by a process other than the defragmenter. There's also the MFT. Clusters of these types can not be moved. [Rus97]

The above is fine for FAT partitions. However, extra complications exist for NTFS partitions. The first problem is that NTFS performs compression on 16 cluster segments. As a result, MoveFile can not move individual clusters. Clusters must be moved in blocks of 16. The other problem is that deallocated clusters can't be used again until NTFS has checkpointed the drive, which occurs once every few seconds. [Rus97]


next up previous contents
Next: Third Party Disk Defragmentation Up: Disk Defragmenter Previous: Windows 98
Barnett Hsu
1998-10-31