Disk Defragmentation

If you have already read my web page "FAT and the directory structure", you must have a concept that under MS-DOS a file is stored on a disk and is referred to a chain of entries in the FAT. A file may not be stored contiguously. Since reading disk sectors sequentially is faster than reading sectors randomly, a file stored contiguously can be accessed in a shorter time. What's more, Windows uses prefetch disk buffering, which speeds up disk access by reading a set of contiguous sectors at once. It would be utilized better if every file is stored contiguously on a disk.
 
Free space on a disk is represented by zero entries in the FAT. If the free space consists of only one block, newly created files will be stored on the disk contiguously by default. Fragments of files grow when there is file modification or file overwriting or file creation after deletion, especially when the largest free space block is insufficient for the increase of a file. The grow of file fragments is often slow, for the OS may utilize the free space better to avoid new file fragments. So usually, a hard disk needs defragmentation about every two months. File fragments are not harmful to disk storage. It only slows down the performance of the computer.
 
To defragment a disk, you can use the tool called DEFRAG provided with MS-DOS or Windows. You can also use third party tools. There is another way if you have enough free hard disk space, or if you can borrow another hard disk that is big enough. It is as follows: copy the files on the disk you want to defragment to another disk. Then format the disk. Then copy the files back and delete the files on the borrowed disk. This is usually fast, but requires more disk space. Notice that this operation should not be applied to the bootable partition.
 
The following is a screen shot of DEFRAG.EXE under MS-DOS:
 
Return to MS-DOS for Beginners