Windows 98, Windows Me and Windows XP come with a collection of house cleaning tools, including ScanDisk, Disk Defragmenter and Disk Cleanup, to help keep your disk in peak working order.
Why should you bother with the housework? A couple of reasons. First, disks are hard working, mechanical devices and, like all mechanical devices, prone to failure. A little preventative maintenance can warn you of potential problems and fix minor glitches before they can do damage to your data.
Second, the way files are organised on your drive has a perceptible impact on the performance of your computer. If your files are stored neatly, end-to-end, without fragmentation, reading and writing to the disk is speedier.
What is file fragmentation?
Sometimes when you install a program or create a data file, the file ends up chopped up into chunks and stored in multiple locations on the disk. This is called fragmentation.
What makes this happen?
When you first install your operating system and programs on your hard disk, they are written to the disk, for the most part, in one contiguous block without any gaps. The exceptions are certain system files that must be stored in specific locations. Over time, as you create and then delete documents or uninstall programs, once-filled locations are left empty and you end up with files dotted all over the disk.
Now, when Windows is writing a file to the disk, it looks for a suitable piece of free space in which to store it. What happens, then, when you copy a 40MB database or a 100MB video clip to the disk and the biggest slice of free space is only 30MB? Or say you modify an existing file, appending a whole bunch of data so the file now takes up more space on the disk. To accommodate the files, Windows writes the first part of the file in one section of the disk and then scouts around for other places to store the rest of the file. The end result is that a single file may be stored in several chunks scattered about the disk.
Of FAT and files
Your operating system needs to have a way of keeping track of each file’s location. Windows 98 and Windows Me use a system called FAT32. The ‘FAT’ stands for File Allocation Table. When your file is written to disk, FAT32 provides Windows with the address of an unoccupied disk cluster. FAT32 also tells Windows on which disk sectors it will find that cluster; that is, it provides the physical location of the cluster. This information is used by your PC’s BIOS (the Basic Input/Output System) to direct the actual disk writing operation.
If the file is too large to fit in a single cluster, Windows asks FAT32 for another vacant cluster, and another, and another until the whole file is written to disk. If you have lots of free clusters side by side, FAT32 can point Windows to an adjacent series of clusters, resulting in a file which occupies one contiguous chunk of the disk. If no adjacent cluster is available, FAT32 tracks down a space elsewhere on the disk and tells Windows to put the next bit of the file there; and so on until the full file is written to disk.
A record of the clusters used for storing the file is kept by FAT32 so Windows can find the file once more when you want to read it.
The fragmentation penalty
Although this all happens quickly, it makes a lot of work for your hard disk. Its read/write head, which moves across the drive platter from location to location transferring data, has to zip all over the place when saving or opening a single highly fragmented file. (By the way, many disks have more than one read/write head and multiple platters.) If a file is unfragmented, the disk head moves to one location, reads the file in one sequential swoop, and that’s it.
A file stored in, say, four fragments, can easily take twice as long to open as the same file unfragmented, although the actual performance hit you take is affected by other factors, including the total size of the file.
Defragging
There’s a simple solution to file fragmentation: use Windows Disk Defragmenter. To do so, click:
Start –> (All) Programs –> Accessories –> System Tools –> Disk Defragmenter
This utility, commonly called Defrag, gathers all the scattered file fragments and writes them into adjacent clusters, so each file occupies an unbroken section of the disk.
Defrag works by moving slabs of data to unused parts of the disk, in order to open up a large free section of space. It then assembles the fragmented parts of a file and writes them in one complete piece to the cleared space; it then does the same with the next file; and so on until the entire disk is defragmented.
Powerful alternatives
The built-in Disk Defragmenter is a utility which has been hobbled by the rapid advance of drive technology. It works just fine on a disk of 8G or so; but use it on a 20G drive or – if you dare – an even larger drive and you can say goodbye to using your computer for the most part of a day. Although Microsoft says it’s okay for you to use your computer while defragging, in practice this rarely works, because every write to disk causes Defrag to restart.
If you’d like to speed up Defrag and eliminate some of its problems, try one of the commercial defraggers. They’re far more at home with large hard drives, run on all versions of Windows from XP onwards, and they provide a less frustrating experience. Some of the alternatives are:
Step-by-step: Efficient defragging
- Defrag works most efficiently when your drive has ample space for its operations. If you run Defrag with a drive that’s chockablock, it must work like mad simply to clear enough space to start writing files. So it pays to delete all unnecessary files before you start defragging. Uninstall unwanted programs, archive old data, delete unwanted backups, and then run Disk Cleanup (Start –> (All) Programs –> Accessories –> System Tools –> Disk Cleanup).
- Defrag also works best when completely uninterrupted. Background programs such as Task Scheduler and anti-virus software can cause Defrag to stop and restart repeatedly. To avoid such interruptions, do a clean boot before running Defrag:
a. Click Start –> Run, type msconfig in the Open box and click OK to open the System Configuration Utility.
b. On the General tab, click Selective Startup and remove the ticks beside Process System.ini File, Process Win.ini File and Load Startup Group Items. (On some versions of Windows you may also see Config.sys, Autoexec.bat and Winstart.bat options – remove the ticks beside these as well).
c. Click OK and allow your computer to restart.
- Once you’ve cleaned out unnecessary files and stopped background programs from loading, you’re ready to defrag:
a. Click Start –> Programs –> Accessories –> System Tools –> Disk Defragmenter.
b. Select the drive you wish to defrag.
c. Click Settings and make sure there’s a tick beside the two options in the section When Defragmenting My Hard Drive, then click OK twice to begin.
d. After Defrag has finished, open the System Configuration Utility once more, click Normal Startup on the General tab, click OK and reboot.