How to Optimize and Defragment Drives in Windows 10
One of the best ways you can improve your PC's performance is by optimizing the drive. Windows includes features to help optimize the different types of drives that PCs use today. No matter which type of drive your PC uses, Windows automatically chooses the optimization that's right for your drive.
By default, Optimize Drives, previously called Disk Defragmenter, runs automatically on a weekly schedule at the time set in automatic maintenance. But you can also optimize drives on your PC manually.
See also: The real and complete story - Does Windows defragment your SSD? | SCOTT HANSELMAN
This tutorial will show you how to manually optimize drives to defrag a HDD or TRIM a SSD in Windows 10.
You must be signed in as an administrator to be able to optimize drives.
If the drive is being used by another program, or is formatted using a file system other than ReFS, NTFS, FAT, or FAT32, it can't be optimized.
Network drives can't be optimized.
If a drive isn't appearing in Optimize Drives, it might be because it contains an error. Try to repair the drive with chkdsk first, then return to Optimize Drives to try again.
The Defrag log file is saved in Event Viewer > Windows Logs > Application, right click on Application, click on Filter Current Log, select Defrag in the Event sources drop menu, and click on OK.
Contents
- Option One: To Optimize Drives in Optimize Drives Tool
- Option Two: To Optimize Drives in Command Prompt
- Option Three: To Optimize Drives in PowerShell
1 Do step 2 (File Explorer ribbon), or step 3 (drive properties), or step 4 (Settings) below for how you would like to open Optimize Drives.
A) Open This PC in File Explorer (Win+E).
B) Select any hard drive, click/tap on the Drive Tools Manage tab, click/tap on Optimize button in the ribbon, and go to step 5 below. (see screenshot below)
A) Open This PC in File Explorer (Win+E).
B) Right click or press and hold on any hard drive, and click/tap on Properties. (see screenshot below)
C) Click/tap on the Tools tab, click/tap on the Optimize button, and go to step 5 below. (see screenshot below)
A) Open Settings, and click/tap on the System icon.
B) Click/tap on Storage on the left side, click/tap on the Optimize Drives link under the More storage settings section on the right side, and go to step 5 below. (see screenshot below)
5 Select a drive you want or need to optimize, and click/tap on the Optimize button. (see screenshots below)
- You can select a drive and click/tap on the Analyze button to see if it needs to be optimized.
- If the drive is more than 10% fragmented, then it should be optimized.
- Optimizing a drive might take anywhere from several minutes to a few hours to finish, depending on the size of the drive and degree of optimization needed.
- You can still use your PC during the optimization process.
Starting with Windows 10 build 20241, Microsoft is making a few changes to Optimize Drives.
- Adding a new Advanced View checkbox to list all volumes including hidden volumes. Please note Microsoft is still getting this one up and running, so you’ll see the checkbox in this build, but may not notice any differences when you click it.
- Listing more details in the “Current status” column when volumes are not available for defrag (for example, “Partition type not supported” and “File system type not supported”).
- Adding support for pressing F5 to refresh.
1 Do step 2 or step 3 below for how you would like to run the defrag command.
A) Open a command prompt at boot.
B) Typediskpart
into the command prompt, and press Enter.
C) Typelist volume
into the command prompt, and press Enter.
Make note of the drive letter that you want to optimize. The drive letter for the drive will not always be the same at boot as it is in Windows.
D) Typeexit
into the command prompt, press Enter, and go to step 4 below.
4 Type the command below you want to use into the command prompt, and press Enter.
Commonly Used Commands:
defrag C: /O
Substitute C: in the command with the drive letter you want instead.
OR
defrag /C /O
For all HDDs and SSDs.
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 | /X
Or, to track an operation already in progress on a volume: defrag <volume> /T
Parameters:
Value Description /A Perform analysis on the specified volumes. /B Perform boot optimization to defrags the boot sector of the boot volume. This will not work on a SSD. /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. /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. Only for a SSD. /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 more Optimize-Volume command usage options, see: Optimize-Volume
1 Open an elevated PowerShell.
2 Do step 3 (analyze), step 4 (optimize), step 5 (TRIM), step 6 (defrag) below for what command you want to use.
A) Type the command below into PowerShell, press Enter, and go to step 7 below.
Optimize-Volume -DriveLetter <drive letter> -Analyze –Verbose
Analyzes the volume specified for fragmentation statistics. Performs analysis only and reports the current optimization state of the volume.
Substitute <drive letter> in the command above with the actual drive letter you want to analyze.
For example:Optimize-Volume -DriveLetter C -Analyze -Verbose
A) Type the command below into PowerShell, press Enter, and go to step 7 below.
Optimize-Volume -DriveLetter <drive letter> -Verbose
Automatically performs the proper optimization (TRIM or defrag) for the drive.
Substitute <drive letter> in the command above with the actual drive letter you want to optimize.
For example:Optimize-Volume -DriveLetter C -Verbose
Do not use this command on a hard drive (HDD spinner).
A) Type the command below into PowerShell, press Enter, and go to step 7 below.
Optimize-Volume -DriveLetter <drive letter> -ReTrim -Verbose
Generates TRIM and Unmap hints for all currently unused sectors of the volume, notifying the underlying storage that the sectors are no longer needed and can be purged. This can recover unused capacity on thinly provisioned drives.
Substitute <drive letter> in the command above with the actual drive letter of the SSD you want to TRIM.
For example:Optimize-Volume -DriveLetter C -ReTrim -Verbose
Do not use this command on a solid state drive (SSD).
A) Type the command below into PowerShell, press [key]Enter[/key, and go to step 7 below.
Optimize-Volume -DriveLetter <drive letter> -Defrag -Verbose
Indicates that the cmdlet initiates defragmentation on the specified volume. Defragmentation consolidates fragmented regions of files to improve performance of sequential reads or writes.
Substitute <drive letter> in the command above with the actual drive letter of the hard drive you want to defrag.
For example:Optimize-Volume -DriveLetter C -Defrag -Verbose
7 When finished, you can close PowerShell if you like.
That's it,
Shawn Brink
Related Tutorials
- How to Change Schedule Settings for Optimize Drives in Windows 10
- How to Change Automatic Maintenance Settings in Windows 10
- How to Add or Remove Optimize Drives context menu in Windows 10
- How to Enable or Disable TRIM Support for Solid State Drives (SSD) in Windows 10
- How to Check a Drive for Errors in Windows 10
- How to Use Storage Diagnostic Tool in Windows 10
- How to Check Drive Health and SMART Status in Windows 10