Disk Defragmenter

Disk Defragmenter is a system utility for analyzing local volumes and locating and consolidating fragmented files and folders. You can also defragment disks from a command line using the defrag command.

  • Before defragmenting files or folders, see Checklist: Defragmenting volumes.
  • For tips about using Disk Defragmenter, see Best practices.
  • For help with specific tasks, see How to.
  • For general background information, see Concepts.
  • For problem-solving instructions, see Troubleshooting.


Checklist: Defragmenting volumes

Step | Reference
Review the overview. | Disk Defragmenter overview
Review best practices. | Best practices
Confirm that you are a member of the Administrators group.

If you have access to the administrator account and password, it is a security best practice to log on as a user that is not a member of the Administrators group and run Disk Defragmenter by right-clicking the Disk Defragmenter icon, and then clicking Run as.

 Default local groups;
Why you should not run your computer as an administrator;
To run a program with administrative credentials
Analyze the volume. | To analyze a volume
Defragment the volume. | To defragment a volume
Review the report. | Analysis and defragmentation reports


Best practices

Analyze before defragmenting a volume

  • Analyze volumes before defragmenting them. After analyzing a volume, a dialog box tells you the percentage of fragmented files and folders on the volume and recommends whether to defragment the volume. Analyze volumes regularly and defragment them only when Disk Defragmenter recommends it. A good guideline is to analyze volumes at least once a week. If you seldom need to defragment volumes, analyze volumes monthly instead of weekly.

Analyze after large numbers of files are added

  • Volumes might become excessively fragmented when users add a large number of files or folders, so be sure to analyze volumes after this happens. Generally, volumes on busy file servers should be defragmented more often than those on single-user workstations.

Ensure that your volume has at least 15% free space

  • A volume must have at least 15% free space for Disk Defragmenter to completely and adequately defragment it. Disk Defragmenter uses this space as a sorting area for file fragments. If a volume has less than 15% free space, Disk Defragmenter will only partially defragment it. To increase the free space on a volume, delete unneeded files or move them to another disk.

Defragment during low-usage periods

  • Defragment file server volumes during low-volume usage periods to minimize the effect that the defragmentation process has on file server performance. The time that Disk Defragmenter takes to defragment a volume depends on several factors, including the size of the volume, the number of files on the volume, the number of fragmented files, and available system resources.

Defragment after installing software or installing Windows

  • Defragment volumes after installing software or after performing an upgrade or clean install of Windows. Volumes often become fragmented after installing software, so running Disk Defragmenter helps to ensure the best file system performance.


How to...

  • Analyze a volume
  • Defragment a volume


Analyze a volume

Microsoft Windows graphic

To analyze a volume

Using the Windows interface

  1. Open Disk Defragmenter.
  2. Click the volume that you want to check for fragmented files and folders, and then click Analyze.

    3. When Disk Defragmenter finishes analyzing the volume, it displays its analysis of the volume in Estimated disk usage before defragmentation. It also displays a dialog box that tells you whether you need to defragment the volume.

  3. Click View Report to view the analysis report, which displays more detailed volume information and a list of the most fragmented files.

Notes

  • XOX
  • XOX
  • Running the defrag command and Disk Defragmenter are mutually exclusive. If you are using Disk Defragmenter to defragment a volume and you run the defrag command at a command prompt, the defrag command fails. Conversely, if you run the defrag command, and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.

Using a command line

  1. Open Command Prompt.
  2. Type defrag volume [/a] [/v]
    3. Value | Description
volume | The drive letter or a mount point of the volume to be analyzed.
/a | Analyzes the volume, displays a summary of the analysis report, and indicates whether you should defragment the volume.
/v | Displays the complete analysis report.

Notes

  • XOX
  • XOX
  • To view the complete syntax for this command, type defrag /?
  • While defrag is analyzing and defragmenting a volume, it displays a blinking cursor. When defrag is finished analyzing and defragmenting the volume, it displays the analysis report, the defragmentation report, or both reports, and then exits to the command prompt.
  • By default, defrag displays a summary of both the analysis and defragmentation reports if you do not specify the /a or /v parameters.
  • You can send the reports to a text file by typing >filename.txt, where filename.txt is a file name you specify. For example:

    • defrag volume /v >filename.txt

  • Running the defrag command and Disk Defragmenter are mutually exclusive. If you are using Disk Defragmenter to defragment a volume and you run the defrag command at a command prompt, the defrag command fails. Conversely, if you run the defrag command, and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.

Related Topics


Defragment a volume

Microsoft Windows graphic

To defragment a volume

Using the Windows interface

  1. Open Disk Defragmenter.
  2. Click the volume that you want to defragment, and then click Defragment.

    3. After the defragmentation is complete, Disk Defragmenter displays the results in Estimated disk usage after defragmentation.

  3. Click View Report to view the Defragmentation Report, which displays detailed information about the volume you defragmented.

Notes

  • XOX
  • XOX
  • You should analyze volumes before defragmenting them. This tells you whether you need to take the time to defragment them.
  • A volume must have at least 15% free space for Disk Defragmenter to completely and adequately defragment it. Disk Defragmenter uses this space as a sorting area for file fragments. If a volume has less than 15% free space, Disk Defragmenter will only partially defragment it. To increase the free space on a volume, delete unneeded files or move them to another disk.
  • You cannot defragment volumes that the file system has marked as dirty, which indicates possible corruption. You must run chkdsk on a dirty volume before you can defragment it. You can determine if a volume is dirty by using the fsutil dirty query command. For more information about chkdsk and fsutil dirty, see Related Topics.
  • The time that Disk Defragmenter takes to defragment a volume depends on several factors, including the size of the volume, the number and size of files on the volume, the percentage of fragmentation in the volume, and available system resources.
  • You can defragment only local file system volumes, and you can run only one instance of Disk Defragmenter at a time.
  • To stop or temporarily interrupt defragmenting a volume, click Stop or Pause, respectively.
  • If you start Disk Defragmenter while performing a backup on the same volume, Disk Defragmenter stops.
  • Running the defrag command and Disk Defragmenter are mutually exclusive. If you are using Disk Defragmenter to defragment a volume and you run the defrag command at a command prompt, the defrag command fails. Conversely, if you run the defrag command, and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.

Using a command line

  1. Open Command Prompt.
  2. Type defrag volume [/v]
    3. Value | Description
volume | The drive letter or a mount point of the volume to be defragmented.
/v | Displays the complete analysis and defragmentation reports.

Notes

  • XOX
  • XOX
  • To view the complete syntax for this command, type defrag /?
  • A volume must have at least 15% free space for defrag to completely and adequately defragment it. Defrag uses this space as a sorting area for file fragments. If a volume has less than 15% free space, defrag will only partially defragment it. To increase the free space on a volume, delete unneeded files or move them to another disk.
  • You cannot defragment volumes that the file system has marked as dirty, which indicates possible corruption. You must run chkdsk on a dirty volume before you can defragment it. You can determine if a volume is dirty by using the fsutil dirty query command. For more information about chkdsk and fsutil dirty, see Related Topics.
  • While defrag is analyzing and defragmenting a volume, it displays a blinking cursor. When defrag is finished analyzing and defragmenting the volume, it displays the analysis report, the defragmentation report, or both reports, and then exits to the command prompt.
  • By default, defrag displays a summary of both the analysis and defragmentation reports if you do not specify the /a or /v parameters.
  • You can send the reports to a text file by typing >filename.txt, where filename.txt is a file name you specify. For example:

    • defrag volume /v >filename.txt

  • To stop the defragmentation process, at the command prompt, press CTRL+C.
  • If you run defrag while performing a backup on the same volume, defrag stops.
  • Running the defrag command and Disk Defragmenter are mutually exclusive. If you are using Disk Defragmenter to defragment a volume and you run the defrag command at a command prompt, the defrag command fails. Conversely, if you run the defrag command, and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.

Related Topics


Concepts

This section covers:

  • Disk Defragmenter overview
  • Understanding Disk Defragmenter
  • Resources


Disk Defragmenter overview

Disk Defragmenter and the defrag command analyze local volumes and consolidate fragmented files and folders so that each occupies a single, contiguous space on the volume. As a result, your system can access files and folders and save new ones more efficiently. By consolidating your files and folders, Disk Defragmenter also consolidates a volume's free space, making it less likely that new files will be fragmented. The process of consolidating fragmented files and folders is called defragmentation.

The amount of time that defragmentation takes depends on several factors, including the size of the volume, the number and size of files on the volume, the amount of fragmentation, and the available local system resources. You can find the fragmented files and folders before defragmenting them by analyzing the volume first. You can then see how fragmented the volume is and decide whether you would benefit from defragmenting the volume. For step-by-step instructions describing how to analyze or defragment a volume, see To analyze a volume and To defragment a volume.

Disk Defragmenter can defragment volumes that are formatted with the file allocation table (FAT) file system, the FAT32 file system, and the NTFS file system.


Understanding Disk Defragmenter

This section covers:

  • Why volumes become fragmented
  • Why files are not moved to some regions of NTFS-formatted volumes
  • Disk Defragmenter window
  • Analysis and defragmentation reports


Why volumes become fragmented

Volumes become fragmented as users create and delete files and folders, install new software, or download files from the Internet. Computers typically save files in the first contiguous free space that is large enough for the file. If a large enough free space is not available, the computer saves as much of the file as possible in the largest available space and then saves the remaining data in the next available free space, and so on.

After a large portion of a volume has been used for file and folder storage, most of the new files are saved in pieces across the volume. When you delete files, the empty spaces left behind fill in randomly as you store new ones.

The more fragmented the volume is, the slower the computer's file input/output performance will be.


Why files are not moved to some regions of NTFS-formatted volumes

On volumes formatted with the NTFS file system, Windows reserves a portion of the free space called the master file table (MFT) Zone, as a space where the MFT can grow. Windows stores all the information necessary to retrieve files from the volume in the MFT.

Disk Defragmenter does not move files to the MFT Zone because it is reserved by Windows. However, Windows allows other files to be saved in the space reserved for the MFT Zone when no other disk space is available.


Disk Defragmenter window

The Disk Defragmenter window consists of two main areas. The upper portion lists the volumes on the local computer. The lower portion displays a graphical representation of the amount of fragmentation on the volume in colored horizontal displays called Estimated disk usage before defragmentation and Estimated disk usage after defragmentation.

Each bar under Estimated disk usage before defragmentation and Estimated disk usage after defragmentation represents a grouping of dozens or even hundreds of clusters, depending on the size of the volume and the cluster. The displays are not large enough to depict each disk cluster in a volume as a vertical colored bar.

Disk Defragmenter does not attempt to consolidate all of the free space on a volume. Although free space fragmented into hundreds of pieces adversely affects performance, free space split into a few pieces does not. Having all of the free space consolidated in a single location provides very little performance benefit. Because fragmented files, contiguous files, files that cannot be relocated from their current positions on the disk (unmovable files), and free space can all reside in the same group of clusters, the color of each vertical bar is determined by the following rules:

Color | Description
Red | Most of the clusters are part of a fragmented file.
Blue | Most of the clusters are contiguous files with clusters in the group that contain only free space and contiguous clusters.
Green | Most of the clusters are part of a file that cannot be moved from its current location. On volumes formatted using the file allocation table (FAT), FAT32, or NTFS file system, the green areas typically represent paging files, which are also called swap files. On volumes formatted using the NTFS file system, however, they may also represent space used by the NTFS Change journal and the NTFS log file.
White | Most of the clusters are free space and contiguous clusters.

By comparing Estimated disk usage before defragmentation to Estimated disk usage after defragmentation, you can view the improvement in your volume after defragmenting it. The display shows less detail than the reports, so if you compare the results, you might notice discrepancies. For precise, numerical figures, see Analysis and defragmentation reports.

For step-by-step instructions describing how to analyze or defragment a volume, see To analyze a volume and To defragment a volume.


Analysis and defragmentation reports

You can view the Analysis and Defragmentation Reports after analyzing or defragmenting a volume. The Analysis and Defragmentation Reports provide detailed information about the volume that was scanned for fragmented files, including the volume size, the amount of free space available, the number of fragmented files and folders, and the average number of fragments per file.

For instructions on how to analyze a volume and view the report, see To analyze a volume. For instructions on how to defragment a volume and view the report, see To defragment a volume.

Analysis Report

You can view or print the Analysis Report only after you analyze a volume. The Analysis Report dialog box displays detailed information about the volume that was scanned for fragmented files and folders, including the path and name of the most fragmented files on the volume, and the number of fragments those files are in, the volume size, the amount of free space available, and the average number of fragments per file. If you use these files frequently, the impact on your system performance might be greater than indicated in Average fragments per file.

The average number of fragments per file is a good indicator of how fragmented the files on the volume are. The following table describes the possible averages and what they indicate:

Average fragments per file | Description
1.00 | Most or all files are contiguous.
1.10 | About ten percent of the files are in fragments of two or more pieces.
1.20 | About twenty percent of the files are in fragments of two or more pieces.
1.30 | About thirty percent of the files are in fragments of two or more pieces.
2.00 | Most or all of the files are in fragments of two or more pieces.

Defragmentation Report

You can view or print the Defragmentation Report only after you defragment a volume. The Defragmentation Report dialog box displays detailed information about the volume that was defragmented. The second half of the Defragmentation Report lists any files that were not defragmented.

If the volume is formatted with the NTFS file system and a file is open and writable, the defragmentation report might show small files (for example, 1 KB in size) with a large number of fragments. This is because when a writable file is open, NTFS attempts to allocate additional space to help prevent fragmentation as the file grows. Because Disk Defragmenter does not allow the extra space to be moved and consolidated while the file is open, the extra space is shown as additional fragments in the report.


Resources

  • Disk Defragmenter was developed by Executive Software International in cooperation with Microsoft. For more information about Executive Software International, see the Executive Software International Web site.
  • You can learn more about Disk Defragmenter in "Troubleshooting Disks and File Systems" at the Microsoft Windows Resource Kits Web site (http://www.microsoft.com/). The Microsoft Windows Resource Kits provide information technology professionals with the technical information and tools they need to successfully deploy, manage, and support Windows operating systems.

    • XOX


Troubleshooting

What problem are you having?

Computer is running slowly or opening programs on the hard disk has become slow.

Cause: The volumes on your hard disk may have become excessively fragmented, possibly because you have recently created a large number of files or folders or have installed new software.

Solution: Analyze and then defragment the volumes on your hard disk if necessary. For more information, see Best practices.

The display and report do not agree.

Cause: The Estimated disk usage before defragmentation and Estimated disk usage after defragmentation displays provide a general view of a volume's fragmentation. The displays show less detail than the Analysis and Defragmentation reports, so if you compare the results you might notice discrepancies. For precise, numerical figures, always use the reports.

Solution: Use the Estimated disk usage before defragmentation and Estimated disk usage after defragmentation displays only for a general idea of the volume's fragmentation. Use the Analysis and Defragmentation reports for precise, numerical figures. For more information, see Analysis and defragmentation reports.

There appear to be unmovable files on volumes other than the system volumes and boot volumes.

Cause: Paging files appear as unmovable files in Disk Defragmenter. On NTFS volumes the NTFS change journal also appears as an unmovable file.

Solution: This is intentional because paging files cannot be moved and therefore cannot be defragmented. For more information, see Why files are not moved to some regions of NTFS-formatted volumes.

The defragmentation report on an NTFS volume shows small files with a large number of fragments.

Cause: When a file is open for write access, the NTFS file system attempts to allocate additional space to help prevent fragmentation as the file grows. When you defragment a volume, Disk Defragmenter does not allow the extra space to be moved and consolidated while the file is open. The extra space is shown as additional fragments in the report.

Solution: Close the file to release the additional fragments and reduce the size of the file. The Size on disk value (right-click the file and then click Properties) reports the size that you would obtain if you closed the file.