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.


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

Additional references