Home > Articles > Home & Office Computing > Microsoft Windows Vista & Home Server

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Defragmenting Your Hard Disk

Windows Vista comes with a utility called Disk Defragmenter that's an essential tool for tuning your hard disk. Disk Defragmenter's job is to rid your hard disk of file fragmentation.

File fragmentation is one of those terms that sounds scarier than it actually is. It simply means that a file is stored on your hard disk in scattered, noncontiguous bits. This is a performance drag because it means that when Windows Vista tries to open such a file, it must make several stops to collect the various pieces. If a lot of files are fragmented, it can slow even the fastest hard disk to a crawl.

Why doesn't Windows Vista just store files contiguously? Recall that Windows Vista stores files on disk in clusters, and that these clusters have a fixed size, depending on the disk's capacity. Recall too that Windows Vista uses a file directory to keep track of each file's whereabouts. When you delete a file, Windows Vista doesn't actually clean out the clusters associated with the file. Instead, it just marks the deleted file's clusters as unused.

To see how fragmentation occurs, let's look at an example. Suppose that three files —FIRST.TXT, SECOND.TXT, and THIRD.TXT—are stored on a disk and that they use up four, three, and five clusters, respectively. Figure 15.5 shows how they might look on the disk.


Figure 15.7 Three files before fragmentation.

If you now delete SECOND.TXT, clusters 5, 6, and 7 become available. But suppose that the next file you save—call it FOURTH.TXT—takes up five clusters. What happens? Well, Windows Vista looks for the first available clusters. It finds that 5, 6, and 7 are free, so it uses them for the first three clusters of FOURTH.TXT. Windows continues and finds that clusters 13 and 14 are free, so it uses them for the final two clusters of FOURTH.TXT. Figure 15.8 shows how things look now.


Figure 15.8 A fragmented file.

As you can see, FOURTH.TXT is stored noncontiguously—in other words, it's fragmented. Although a file fragmented in two pieces isn't that bad, it's possible for large files to split into dozens of blocks.

Running the Disk Defragmenter Tool

new.gif The good news with Windows Vista is that it configures Disk Defragmenter to run automatically—the default schedule is weekly: every Sunday at 4:00 a.m. This means that you should never need to defragment your system manually. However, you might want to run a defragment before loading a particularly large software program.

Before using Disk Defragmenter, you should perform a couple of housekeeping chores:

  • Delete any files from your hard disk that you don't need, as described in the previous section. Defragmenting junk files only slows down the whole process.
  • Check for file system errors by running Check Disk as described earlier in this chapter (refer to "Checking Your Hard Disk for Errors").

Follow these steps to use Disk Defragmenter:

  1. Select Start, All Programs, Accessories, System Tools, Disk Defragmenter. Alternatively, in Windows Explorer, right-click the drive you want to defragment, click Properties, and then display the Tools tab in the dialog box that appears. Click the Defragment Now button. Either way, the Disk Defragmenter window appears, as shown in Figure 15.9.

    Figure 15.9 Use Disk Defragmenter to eliminate file fragmentation and improve hard disk performance.

  2. Click Defragment Now. Windows Vista defragments your hard drives.
  3. When the defragment is complete, click Close.

Changing the Disk Defragmenter Schedule

If you want to run Disk Defragmenter on a different day, at a different time, more often or less often, follow these steps to change the default schedule:

  1. Select Start, All Programs, Accessories, System Tools, Disk Defragmenter.
  2. Make sure that the Run On a Schedule check box is activated.
  3. Click Modify Schedule to display the Disk Defragmenter: Modify Schedule dialog box.
  4. Use the How Often list to select the defragment frequency: Daily, Weekly, or Monthly.
  5. For a Weekly schedule, use the What Day list to select the day of the week on which to run the defragment; for a Monthly schedule, use the What Day list to select the day of the month on which to run the defragment.
  6. Use the What Time list to select the time of day to run the defragment.
  7. Click OK to return to the Disk Defragmenter window.
  8. Click Close.

Defragmenting from the Command Line

If you want to schedule a defragment or perform this chore from a batch file, you have to use the DEFRAG command-line utility. (You need an Administrator command line to run DEFRAG. Select Start, All Programs, Accessories, right-click Command Prompt, and then click Run as Administrator.) Here's the syntax:

   [-c] [-a] [-f] [-v]




Specifies the drive letter (followed by a colon) of the disk you want to defragment.


Tells DEFRAG to defragment all the system's drives.


Tells DEFRAG only to analyze the disk.


Forces DEFRAG to defragment the disk, even if it doesn't need defragmenting or if the disk has less than 15% free space. (DEFRAG normally requires at least that much free space because it needs an area in which to sort the files.)


Runs DEFRAG in verbose mode, which displays both the analysis report and the defragmentation report.

  • + Share This
  • 🔖 Save To Your Account