Bijgewerkt: september 2007

Van toepassing op: Windows Server 2008, Windows Vista

Locates and consolidates fragmented files on local volumes to improve system performance.

Membership in the local Administrators group, or equivalent, is the minimum required to run this command.

For examples of how this command can be used, see Examples.


defrag <volume> -a [-v]
defrag <volume> [{-r | -w}] [-f] [-v]
defrag -c [{-r | -w}] [-f] [-v]



Parameter Description


Specifies the drive letter or mount point path of the volume to be defragmented or analyzed.


Defragments all volumes on this computer.


Performs fragmentation analysis only.


Performs partial defragmentation (default). Attempts to consolidate only fragments smaller than 64 megabytes (MB).


Performs full defragmentation. Attempts to consolidate all file fragments, regardless of their size.


Forces defragmentation of the volume when free space is low.


Specifies verbose mode. The defragmentation and analysis output is more detailed.


Displays this help information.


  • You cannot defragment specific types of file system volumes or drives:

    • You cannot defragment volumes that the file system has locked.

    • 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 Additional references.

    • You cannot defragment network drives.

    • You cannot defragment CDROMs.

    • You cannot defragment file system volumes that are not NTFS, FAT or FAT32.

  • With Windows Server® 2008 R2, Windows Server 2008, and, Windows Vista®, you can schedule to defragment a volume. However, you cannot schedule to defragment a Solid State Drive (SSD) or a volume on a Virtual Hard Disk (VHD) that resides on an SSD.

  • To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.

  • 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.

  • 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: defragVolume/v>FileName.txt

  • To interrupt the defragmentation process, at the command line, press CTRL+C.

  • 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-line, the defrag command fails. Conversely, if you run the defrag command and open Disk Defragmenter, the defragmentation options in Disk Defragmenter are unavailable.


To defragment the volume on drive D, type:

defrag d:

To defragment all volumes on your computer, type:

defrag -c

To perform a full defragmentation of a volume mounted on drive D, even if free space on the drive is low, type:

defrag d:\vol\mountpoint – w -f

To perform a fragmentation analysis of drive D, and to see a detailed output of the results, type:

defrag d: -a -v