This post explains various methods you can use to defragment a drive in Windows 10, including the graphical tool ‘MMC’, the console defrag
command, and PowerShell.
Optimizing your PC’s internal hard drive is a very important process that improves the performance of your computer. Fortunately, Windows includes tools to complete this important process.
Windows 10 automatically performs disk defragmentation using the following schedule:
- for NTFS hard drives – once a week.
- SSD TRIM operation for SSD(s) – also once a week.
During active use, hard disk performance suffers due to file system fragmentation, which significantly slows down access time. SSDs have very fast access time to data stored in any part of the disk and do not need to be defragmented, but they need to send a TRIM command, which tells the SSD controller to erase unused blocks that are no longer in use, so that when it comes time to actually write new ones data in these blocks, performance is not affected.
Modern Windows versions are smart enough to pick the right optimization method and time period depending on your drive specifications. If you want, you can optimize your drives manually to ensure that you have the best performance of the OS.
To defrag a drive in Windows 10,
- Open File Explorer.
- Click on This PC in the left pane.
- Right-click on the drive you want to defragment.
- Select Properties from the context menu.
- Open the Tools tab and click/tap on the button Optimize under Optimize and defragment drive.
- Click on the Analyze button to see if the drive needs to be optimized. The button is not available if you have already analyzed the drive.
- To optimize the drive, click the Optimize button. If the file system on drive is more than 10% fragmented, then you should optimized it.
Defrag a Drive in Command Prompt
There is a way to optimize drives in the command prompt. Here is how it can be done.
- Open a command prompt as Administrator.
- Type the following command to optimize your C: drive:
defrag C: /O
- Replace the C: portion with the drive letter you need to optimize and defrag,
The defrag command supports the following command line arguments and options.
Syntax:
defrag <volumes> | /C | /E <volumes> [<task(s)>] [/H] [/M [n] | [/U] [/V]] [/I n]
Where <task(s)> is omitted (traditional defrag), or as follows:
/A | [/D] [/K] [/L] | /O | /XOr, to track an operation already in progress on a volume:
defrag <volume> /TParameters:
Value Description
/A Perform analysis on the specified volumes.
/C Perform the operation on all volumes.
/D Perform traditional defrag (this is the default).
/E Perform the operation on all volumes except those specified.
/G Optimize the storage tiers on the specified volumes.
/H Run the operation at normal priority (default is low).
/I n Tier optimization would run for at most n seconds on each volume.
/K Perform slab consolidation on the specified volumes.
/L Perform retrim on the specified volumes.
/M [n] Run the operation on each volume in parallel in the background.
At most n threads optimize the storage tiers in parallel./O Perform the proper optimization for each media type.
/T Track an operation already in progress on the specified volume.
/U Print the progress of the operation on the screen.
/V Print verbose output containing the fragmentation statistics.
/X Perform free space consolidation on the specified volumes.
For example, you can optimize all your partitions at once, run the command:
defrag /C /O
Defrag a Drive in PowerShell
It is possible to defrag a drive in Windows 10 using PowerShell. You need to use the Optimize-Volume cmdlet. Open an elevated PowerShell and type the command below.
Optimize-Volume -DriveLetter drive_letter -Verbose
Replace the “drive_letter” portion with the actual drive letter of your partition. For example, the following command will optimize the drive D:
Optimize-Volume -DriveLetter D -Verbose
Using this cmdlet, you can analyze the specified partition for fragmentation statistics. The command looks as follows:
Optimize-Volume -DriveLetter C -Analyze -Verbose
This will show the fragmentation statistics for drive C.
If you are using an SSD drive, the following command should be used.
Optimize-Volume -DriveLetter DriveLetter -ReTrim -Verbose
Replace the DriveLetter portion with your solid state drive partition letter.