Defrag command in Windows
The defrag command locates and merges fragmented files on local drives to improve system performance. Local administrator, or equivalent, is the minimum necessary requirement to run this command.
Applies to : Windows Server (Semi-Annual Channel), Windows Server 2016, Windows Server 2012 R2, Windows Server 2012.
The defrag command locates and merges fragmented files on local drives to improve system performance. Local administrator, or equivalent, is the minimum necessary requirement to run this command.
Defrag command in Windows
- Syntax defrag command
- Parameters
- Note
- For example
- Scheduled task
Syntax defrag command
defrag | /C | /E [/H] [/M [n]| [/U] [/V]] defrag | /C | /E /A [/H] [/M [n]| [/U] [/V]] defrag | /C | /E /X [/H] [/M [n]| [/U] [/V]] defrag [/]*
Parameters
ParameterDescription
Specify the drive letter or path to the mount point of the fragmented or analyzed drive. A Perform an analysis of the specified drive. C Perform operations on all drives. D Perform traditional defragmentation (this is the default). However, on a stratified partition, the traditional defragmentation feature is only implemented on Capacity level. E Perform operations on all drives, except for the specified drives. G Optimize storage layers on specified drives. H Running at normal priority (default is low). I n The process of optimizing floors will run for up to n seconds on each drive. K Perform consolidation on the specified drive. L Perform the split again on the specified drive. M [n] Runs operations on each parallel drive in the background process. For up to n threads, it will optimize parallel storage layers. O Perform optimization appropriate for each type of media. T Track an activity that has been performed on the specified drive. U Export the process of action on the screen. V Output detailed output containing fragmented statistics. X Integrate free space on the specified drives. ? Show help information. Note
- You cannot defragment certain types of partitions or specific file system drives:
- You cannot defragment the file system that has been locked.
- You cannot defragment the drive where the file system is marked as dirty, a sign that the system may be corrupted. You must run chkdsk on the dirty drive before you can defragment it. You can determine whether a drive is dirty or not, using the fsutil query command .
- You cannot defragment network drives.
- You cannot defragment cdROM.
- You cannot defragment a file system drive other than NTFS, ReFS, Fat or Fat32.
- With Windows Server 2008 R2, Windows Server 2008 and Windows Vista, you can schedule to defragment a drive. However, you cannot schedule to defragment Solid State Drive (SSD) or drive volumes on Virtual Hard Disk (VHD) located on an SSD.
- To perform this procedure, you must be a member of the Administrators group on the local computer or you must have the appropriate permissions. If the computer is attached to a domain, members of the domain administrator group can perform this procedure. As a best security method, consider using Run As to implement this process.
- The drive must have at least 15% of free space for the defrag command to completely and completely defragment. The defrag command uses this space to classify fragmented files. If a drive has less than 15% of free space, the defragmentation feature will only defragment part of it. To increase free space on the drive, delete unnecessary files or move them to another drive.
- While the defrag command is analyzing and defragmenting a drive, it will show the blinking cursor. When defrag finishes analyzing and defragmenting the drive, it will display the analysis report, report fragmentation, or both reports, and then exit the command prompt.
- By default, defrag displays a summary of both the analysis report and the fragmentation report if you do not specify the / a or / v parameter .
- You can view the report as a text file by entering > FileName.txt , where FileName.txt is the name of the file you specify. For example:
defrag volume /v > FileName.txt
- To interrupt the defragmentation process, at the command line, press CTRL + C.
- Running the defrag command and Disk defragmenter eliminates each other. If you are using the Disk defragmenter to defragment the drive and run the defrag command at the command line, the defrag command will fail. Otherwise, if you run the defrag command and open the Disk defragmenter at the same time, the defragmentation option in Disk defragmenter is also unavailable.
For example
To defragment on drive C and provide detailed results on progress, enter:
defrag C: /U /V
For parallel defragmentation on drives C and D in the background process, enter:
defrag C: D: /M
To perform a defragmentation analysis of the mounted drive on C drive and track progress, enter:
defrag C: mountpoint /A /U
To defragment all drives with normal priority and provide detailed output, enter:
defrag /C /H /V
Scheduled task
The scheduled task of the defrag command acts as a maintenance task and is usually scheduled to run each week. Admin can change the frequency with Optimize Drives application .
- When running from a scheduled task, the defrag command has below the following policy for SSD:
- Traditional defrag (eg moving files to make them arranged in logical order) and retrim only run once a month.
- If both t raditional defrag and retrim are ignored, analysis will not be performed.
- If the user runs t raditional defrag manually on the SSD, 3 weeks after the last scheduled task run, the next scheduled task will perform analysis and retrimination but ignore traditional defrag on the SSD.
- If analysis is ignored, the Last run time in Optimize Drives will not be updated. Therefore, for SSD, the Last run time in Optimize Drives can be calculated in months.
- Sometimes, this maintenance task may not defragment all drives, as this task is performed as follows:
Do not "wake up" the computer to run the defrag command .
- Only start if the computer is on AC power and stop if the computer switches to battery power
- Stop if the computer stops working
See more:
- Cmstp command in Windows
- Dcgpofix command in Windows
- Del command in Windows
You should read it
- The TRIM hard drive error on Windows Defrag has not been fixed
- How to use Smart Defrag to defragment hard drives effectively
- Download Smart Defrag Pro 5, the $ 9.99 price defragmentation app, which is free
- How to Defrag Windows 7
- Del command in Windows
- How to Defrag Windows 10
- Top 5 best hard drive defrag software
- Cmd command in Windows
- How to use Auslogics Disk Defrag to defragment your hard drive
- Fc command in Windows
- Command at in Windows
- The echo command in Windows
Maybe you are interested
Panasonic upgraded the configuration for ultra-durable computers How to use Photoshop CS5 - Part 15: Remove wrinkles with the Healing Brush tool Unfold, an application that helps to create Story content on Facebook Being alone is not eccentric but a sign of people with high IQ 10 simple ways to earn extra income There was a year when the Earth had no summer and the world history was changed