Microsoft Windows - Defragmenting Your Hard Drive

windows logoSo my daughter mentions the other day that her computer "isn't working". Over the years I've learned that this very general, benign description is in reality a secret code for a wide variety of computer ailments, ranging anywhere from the minor:

- some program refuses to do something that she wants it to do, which by the way has absolutely nothing to do with the actual capabilities of that program

to the major:

- there is currently smoke, sparks, and/or flames coming out of said computer

On this particular occasion it meant that the computer, along with half of the other electrical appliances in the room, were completely dead. With some minor investigation I found that a GFCI outlet had tripped, as her desk is in the basement and is protected by these oh-so-sensitive electrical devices. With some slight nervousness I reset the device (as the aforementioned flaming computer could have been the reason it had tripped in the first place), and waited to see what would happen. To my great relief and surprise the computer booted right up, and even managed to recover a Word document that must have been open when the thing had unexpectedly been shut down by the tripping circuit breaker. Feeling lucky, I thought it might be good time to perform a little routine maintenance on the machine, part of which is defragmenting the hard drive.

Your computer's hard drive will become fragmented during the normal course of working with the files and programs that are on it. It will do this for a variety of reasons, most commonly because a file has changed in size since it was first created or because you've deleted programs or files from your computer. When you increase the size of a file the part of the operating system that is in charge of taking care of this stuff (FAT or NTFS on Windows machines) may need to break the file into pieces, as the file may now be larger than the space that was originally allocated for it. Conversely, when you delete files or programs (which really isn't deleting anything, you're actually just telling the operating system that it is now OK to re-use that space) you are leaving spaces in the hard drive that are not being used effectively. A computer that needs to look in many locations to pull a program and/or files into memory for use is not running as efficiently and quickly as it should. When I'm doing a lot of work on large graphics files I'll defragment my hard drive(s) about once a month. The average user, however, shouldn't really need to defragment their hard drive more than a couple of times a year.

Before you start doing this there are a couple of routine items you should take care of. First, close all programs that are currently running on your computer. Next, make sure you've got enough time to let the defragmenter program run. This could take up to several hours to complete, and although you can cancel out of it at any time the task will not be complete until you can let it run through all the way to completion (I will usually do this the last thing at night, and just let it run).

If you are NOT running Windows XP you should go through each of the following before proceeding (if you are using XP there is an easier way to do this, which you'll see in a minute):

  • Empty your Recycle Bin - there's no point in defragmenting items which you are going to discard. In addition, you would be surprised how much stuff builds up there, and you can always use the space.
  • Clean up your browser cache - delete your temporary internet files in all of your browsers. If you're not sure how to do this you can find more information by clicking here. These can take up a considerable amount of space, and as these are temporary files there is no point in optimizing them.
  • Uninstall any programs that you don't use - now is a good time to review your installed programs, and get rid of anything you don't use.
  • Optional - Delete items from your Windows temp directory - Windows will write to a temporary directory (usually C:\Documents and Settings\[your user name]\Local Settings\Temp) during the normal process of running programs. Windows programs have gotten much better at cleaning up after themselves, but you will still find quite a bit of junk here. You will probably not be able to delete everything here, because there may be processes running in the background on your computer that have active files open in this directory. Not to worry, you'll just get a message from Windows that certain files could not be deleted because they are in use by another program or process.

Now, as with most things on your computer there is more than one way to do this. You can get to the disk defragmenter that comes with Windows in Programs -> Accessories -> System Tools, and also by going to Settings -> Control Panel -> Administrative Tools -> Computer Management. However, I think the easiest way is through My Computer. Simply double-click the My Computer icon on your desktop, right-click on your C:\ drive and select Properties from the pop-up menu:

 

windows defragment 01

 

This has the added benefit you giving you a graphic representation of the amount of free space you've got on your hard drive. Operating systems other than XP may look slightly different than this, and of course your hard drive will likely be a different size and utilization than mine. If you are running XP home or professional you will notice the button labeled 'Disk Cleanup':

 

windows defragment 02

 

This is quite the handy little utility, as it goes through all of the preliminary steps I mention above, in a convenient little package. Click on it to see all of the areas that hold less-than-critical files on your computer (it may take a little while to run):

 

windows defragment 03

 

I would recommend that you go through each of these items and carefully read the description before you include the files for deletion. The only item I would not recommend selecting is the Office Setup files, as deleting these files can cause you some considerable grief in the long run. After you've selected the options you would like to include in the clean up process go ahead and click on OK, then select Yes from the confirmation pop up. After that runs you should select the Tools tab at the top of the local drive Properties form, then click on button labeled 'Defragment Now':

 

windows defragment 04

 

Doing so will bring up the Disk Defragmenter dialog form, from which you can choose which hard drive you would like to work with (assuming you have more than one), and whether to analyze the drive or go directly to defragmenting. Personally, I think that analyzing your hard drive is a complete waste of time:

  • First of all, maybe it's better now but this never used to work very well. I remember using this in Windows 95 and being repeatedly told 'Only 1% of your hard drive is fragmented, defragmenting is not necessary...'. It would do this until it actually needed defragmenting, at which point you got a message that was something along the lines of 'Your hard drive is too fragmented to defragment'. This was a little more than slightly irritating.
  • You've come this far, it seems a little pointless at this stage to not complete the task at hand.

So what the heck, why not just go for it. Select the (C) drive and click on the 'Defragment' button:

 

windows defragment 05

 

Doing so will allow the utility will work its magic, analyze your hard drive, and begin the defragmentation process. You will see a graphic representation of your hard drive with a 'before' and 'after' profile. The various types of files are shown with red, blue, green and white keys, giving you the two views of your hard drive. In addition, at the bottom of the form you can see the process that is currently being run:

 

windows defragment 06

 

You can see from my profile that I have been a little lax in my routine computer maintenance procedures (grinning sheepishly, and writing a reminder for myself to defragment my hard drive before turning in for the night...).

Bytes: