How to Defragment and Optimize Drives
Download nowWindows includes both a graphical tool (dfrgui) and a command-line tool (defrag) for optimizing HDDs and issuing TRIM to SSDs.
Updated August 9, 2026 · PC Utility Hub Editorial Team
Using the graphical tool (dfrgui)
- 1Press Start, type "defrag", and open "Defragment and Optimize Drives".
- 2Select the drive you want to check.
- 3Click "Analyze" to see the current fragmentation percentage (HDDs only).
- 4Click "Optimize" to run defragmentation on an HDD or TRIM on an SSD.
- 5Optionally click "Change settings" to adjust or disable the automatic schedule.
Using the defrag command line
The defrag.exe command gives more control and can be scripted or scheduled.
defrag C: /A
defrag C: /O
defrag C: /L
defrag C: /V| Switch | Meaning |
|---|---|
| /A | Analyze only, report fragmentation |
| /O | Optimize based on drive type (defrag HDD or TRIM SSD) |
| /L | Retrim on an SSD (issue TRIM to reclaim unused blocks) |
| /V | Verbose output |
| /U | Show progress during operation |
SSD TRIM and retrim explained
TRIM tells an SSD controller which storage blocks no longer hold valid data so the drive can erase and reuse them efficiently ahead of new writes, which helps maintain write speed over time. Windows issues TRIM continuously as files are deleted, and the scheduled "optimize" task performs a periodic retrim pass (`defrag /L`) as a backstop, rather than a full rewrite of data.
Checking or changing the automatic schedule
- 1Open Defragment and Optimize Drives.
- 2Click "Change settings".
- 3Confirm "Run on a schedule" is checked (weekly is the default).
- 4Choose which drives are included by clicking "Choose".
Leave the default schedule enabled unless you have a specific reason to manage it manually; Windows already treats HDDs and SSDs differently.
When to skip optimization
- Don't manually defragment SSDs or NVMe drives beyond the scheduled TRIM pass.
- Skip defragmenting drives with SMART errors — check disk health first.
- Avoid running defrag on a nearly full drive; free some space first for best results.
Frequently asked questions
- How do I know if my drive is an SSD or HDD in this tool?
- The Media type column in Defragment and Optimize Drives lists each drive as "Solid state drive" or "Hard disk drive".
- What does defrag /L do?
- It issues a retrim to an SSD, telling the controller which blocks are free, without performing traditional defragmentation.
- Can I disable scheduled optimization?
- Yes, uncheck "Run on a schedule" in Change settings, though leaving it enabled is recommended for both HDDs and SSDs.
Related pages
- Disk DefragmenterThe Windows tool for defragmenting HDDs and optimizing SSDs, now called "Optimize Drives."
- CHKDSKOverview of the chkdsk utility, its switches, and how it fits into Windows disk maintenance.
- Disk CleanupThe classic Windows disk cleanup program, still available in Windows 10 and 11, for reclaiming drive space.
- PC Maintenance ChecklistA recurring checklist of built-in Windows tools for disk, update, and drive maintenance.