Recipe 7.8. Defragmenting a Volume


You want to defragment a volume to improve disk access performance.


Using a graphical user interface

  1. Open Windows Explorer.

  2. Right-click the drive you want to defragment and select Properties.

  3. Click the Tools tab.

  4. Click the Defragment Now button. This launches the Disk Defragmenter application.

  5. Click the Analyze button to find out how badly the volume is fragmented. After the analysis is complete, Windows will inform you whether it believes you should defragment the volume.

  6. Click the View Report button to view statistics about fragmentation and to see the most fragmented files.

  7. Click the Defragment button to proceed with defragmenting the volume.

Using a command-line interface

The defrag utility is the command-line version of the Disk Defragmenter application. Run the following command to perform an analysis of the D drive:

> defrag d: /a

Add the /v option to see similar information to the View Report button in Disk Defragmenter:

> defrag d: /a /v

Lastly, just include the drive and /v (for verbose output) to perform a defragmentation of the volume:

> defrag d: /v

You can force a defragmentation even if disk space is low by including the /f option.

Using a downloadable software

Diskeeper from and PerfectDisk from have options for defragmenting disks, including scheduling defragmenting, deploying on multiple machines, and defragmenting boot files. Diskeeper runs in the background and defrags files as they become fragmented, so your disks stay defragmented automatically. Both tools offer trial downloads, although if you keep using them, you'll have to pay.


When you save a file on a volume, Windows tries to save the file in one contiguous section on the disk. However, as the disk becomes full, the largest available contiguous sections of the disk become smaller and smaller. New files eventually become spread over multiple sections of the disk; this is called fragmentation. Fragmentation leads to decreased disk access performance because Windows has to access multiple sections of the disk to piece together a single file.

The Windows defragmentation feature helps alleviate this problem by scanning a disk and attempting to combine the sections of files in larger contiguous portions. To perform a full defragmentation on a volume, the target volume needs to have at least 15% free space. This is necessary because Windows needs some space to store file fragments it is trying to piece together. If you have less than 15% available, you'll need to free up some space first. See Recipe Recipe 7.7 for more details.

You can determine how badly a volume is fragmented by analyzing the volume. All three solutions provide options for generating a report that provides details on the fragmentation level of a volume. The report will also recommend whether you should perform a defragmentation or not. This is useful only as a general guide because it may always recommend that you perform a defragmentation even after you've just run one.

You should consider performing periodic defragmentation on heavily used volumes that have become more than 50% utilized. As disk space decreases on a volume, the level of fragmentation generally increases because the number of contiguous sections of disk decrease. If you have really large disks that are rarely more than 25% used, performing a defragmentation will not likely be of much benefit.

Defragmenting a disk can take several minutes and even hours depending on the size of the disk and the level of fragmentation. Also, the disk will be continually busy during the defragmentation period, so do it during off-hours because disk access performance will definitely decrease.

See Also

Recipe 7.7 for cleaning up a volume; MS KB 283080, "Description of the New Command Line Defrag.exe Included with Windows XP," MS KB 305781, "How To Analyze and Defragment a Disk in Windows XP," and MS KB 312067, "Shadow copies may be lost when you defragment a volume"

Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: