Defragmenting

Fragmentation 101

Fragmentation is a phenomenon that gradually increases on your hard disk as a normal part of file operations. Any PC disk is divided up into little discrete units called "clusters." Any given cluster always either belongs to a particular file, or is marked as available. One file may be stored on dozens or hundreds of clusters. Every time a file gets added, deleted or modified, there's an increasing tendency for various parts of the file to get stored in different places on the disk.

Your computer's file system can cope with fragmentation on a day-to-day basis. It keeps track of where everything is, and when you retrieve a file, it just jumps around and gathers up all the parts. When the disk is fragmented it takes a little longer to retrieve a file than it would if the file were stored contiguously, that is, in one continuous stream of clusters, all physically located together on the disk.

Modern applications use a lot of disk files besides the ones you see; program and DLL files, configuration files, temporary work files etc. The performance hit adds up, and the longer you let it slide, the worse it gets. I once defragmented a PC that had probably been used for two to four years without being defragmented. Defrag took about two hours to finish, and afterward the machine appeared to be about twice as fast at launching programs and loading and saving files.

Linux and other Unix flavors usually don't require defragmentation as a periodic maintenance procedure, if there is a reasonable amount of free disk space, because they minimize fragmentation during normal file operations. This will also tend to be true of other advanced file systems to some extent.


How to fix it

Windows 95 and later has a program called Disk Defragmenter. It's normally in the Start menus under Programs, Accessories, System Tools. All you have to do is run Disk Defragmenter about once every three to six months. If you do it about that often, generally it will only take a few minutes, and your file operations will stay at peak efficiency. More often than once a month is probably not a good idea; there is after all a certain amount of wear and tear inherent in running the defragmenter.

It'd be a good idea to make a backup, and then run Scandisk, before running your defragmenter program. It's probably also safest to have nothing else running on your PC while Defragmenter is running.

If you ever need to stop Disk Defragmenter before it's done, always use its Stop button. Stop makes Defragmenter finish the move it was doing the instant you clicked the button, and then wait; then you can exit Defragmenter without screwing up your file system.

You might also want to look at the Wikipedia article on defragmentation.


Consequences of neglect

If you never defragment your PC, the file system is just going to gradually get more and more complicated the longer it's in use. You probably won't see much effect for the first six months to a year. Eventually you will get to a state where coping with your massively fragmented file system is imposing a significant performance hit on your operating system.

If it gets to be a big enough hairball, and you never let Scandisk run either, probably eventually there will be file system errors, lost or corrupted files, or software/OS corruption. You might lose documents, have to reinstall software, or even have to reformat your hard disk and reinstall Windows and everything else. I suppose some people buy a new PC and start over.


Old-school defragmentation

The official pre-DOS-6 Redmond method of fixing fragmentation was theoretically as follows:

  1. Get yourself a tall stack of floppies and back up your entire hard disk.
  2. Repartition and reformat your hard disk (wiping out everything currently stored).
  3. Restore your complete hard disk from the backup (the restored files will be stored contiguously in the process).

I never saw anybody actually do it that way.

If you have to, you can also semi-fix fragmentation like this:

This second process is what's known among tech support geeks as an R&R, for Reformat and Reinstall, and there are sometimes error conditions that occur on Windows PCs that can only be cured in this way.

  1. Back up just your documents and other data files from My Documents, to the backup device of your choice.
  2. Repartition and reformat your hard disk (wiping out everything currently stored).
  3. Reinstall Windows and all your software from original media.
  4. Restore your data files from your backup.
  5. Re-set all your personal configuration choices in your software.

This method will not result in a completely defragmented system, but it would be a definite improvement over a badly neglected and heavily fragmented one, if for some mysterious reason a regular defragmenter program were not available. Still takes way too long.

Obviously either of these scenarios is less than satisfactory; which is why defragmenter programs were created. A defragmenter fixes the problem in place; it just uses the free space on the disk and moves parts of files around until everything is once again contiguous. The more thoroughly fragmented a disk is, the longer the defragmenter will take to tidy things up.


Problems in 98/ME, sometimes

On some Windows 98 and Windows ME systems, depending on what utilities you have installed, you may find that Disk Defragmenter keeps stopping and starting over, when you try to run it in normal boot mode. This is generally due to utilities or background programs that are changing the disk contents and messing it up. The key symptom is when the progress bar goes back to zero percent. If you have this problem, bottom line, I've found the easiest fix is to boot your computer to Windows safe mode, run the defragmenter in safe mode, and then switch back to normal boot mode.

Windows 98

To boot Windows 98 in safe mode:

  1. Click Start, point to Programs, point to Accessories, point to System Tools, and then click System Information.
  2. On the Tools menu, click System Configuration Utility.
  3. Click the Advanced button, and then click to select the Enable Startup Menu check box.
  4. Click OK, click OK, and then restart your computer when you are prompted to do so.
  5. Select the Safe Mode menu option from the Startup menu, and then press ENTER.

A slightly shorter method:

  1. Click Start, Run, type in "MSCONFIG" without the quotes, and click OK, to launch System Configuration Utility.
  2. Click the Advanced button, and then click to select the Enable Startup Menu check box.
  3. Click OK, click OK, and then restart your computer when you are prompted to do so.
  4. Select the Safe Mode menu option from the Startup menu, and then press ENTER.

Once Windows 98 is booted in safe mode, you can run Defragmenter. You can confirm you're in Windows safe mode by noting the words Safe mode appearing in all four corners of the display, also by a rather verbose dialog box that appears.

To change back to normal boot mode, follow the same directions but uncheck the Enable Startup Menu box, and skip the last step in each method above, because you won't see the startup menu.

Windows ME

Windows ME can be tough to get into safe mode. Here's an alternative method to get ME into a selective startup mode similar to safe mode, in which Defragmenter should run without problems. You can use this method in Windows 98 as well, with the noted variations. This is not a true Windows safe mode, and you will not see "Safe mode" in the display corners.

Windows ME is pretty well discredited these days and you probably won't see it very often.

  1. Launch System Configuration Utility (MSCONFIG) as above.
  2. Select the radio button for Selective startup, and then uncheck the following:
  3. Click OK and restart when prompted.
  4. Run Defragmenter.
  5. Run System Configuration Utility again, set it back to Normal startup, click OK and restart when prompted.

KB articles

286263   List of articles about the Disk Defragmenter tool http://support.microsoft.com/kb/286263/
186978   "Drive's Contents Have Changed: Restarting" message http://support.microsoft.com/kb/186978/
180902   How to start a Windows 98 computer in Safe Mode http://support.microsoft.com/kb/180902/
This article lists four ways to get Windows 98 into safe mode. Try to stick with method 2, which uses the relatively user-friendly System Configuration Utility.

HTML checked
site feedback