To defrag a drive in Windows 11, search the Start menu for Defragment and Optimize Drives, select the drive, and click Optimize. Windows defragments hard disk drives and sends a TRIM (retrim) command to SSDs instead, so the same button is safe for both.
Windows 11 already runs this tool on a weekly schedule, so most PCs don’t need a manual run. It’s worth doing after moving a lot of files onto a traditional hard drive, or if the tool reports high fragmentation.
Quick Answer
Start > type defrag > open Defragment and Optimize Drives > select the drive > Optimize.
How to Defrag a Drive in Windows 11
- Click Start and type defrag.
- Open Defragment and Optimize Drives.
- Check the Media type column. Hard disk drives get defragmented; solid state drives get retrimmed.
- Select a drive and click Analyze (hard drives only) to see the fragmentation percentage.
- Click Optimize. You can keep using the PC while it runs, though it may feel slower on a hard drive.

You can also reach the tool from Settings > System > Storage > Advanced storage settings > Drive optimization.
Should You Defrag an SSD?
No, and Windows won’t. When you click Optimize on an SSD, Windows runs a retrim that tells the drive which blocks are free, which helps keep write speeds up. A traditional defrag would only add wear without a speed benefit. Occasionally Windows may also defragment an SSD that has very high fragmentation for file-system reasons, which is expected behavior and nothing to disable.
| Drive type | What Optimize does | How often |
|---|---|---|
| Hard disk drive (HDD) | Defragments files so they’re stored in one piece | Weekly schedule is enough; manually if above about 10% fragmented |
| Solid state drive (SSD) | Sends TRIM (retrim) | Weekly schedule; no manual runs needed |
| USB flash drive or SD card | Usually not listed or not needed | Rarely |
Check or Change the Automatic Schedule
- In Defragment and Optimize Drives, click Change settings under Scheduled optimization.
- Make sure Run on a schedule (recommended) is checked.
- Choose Daily, Weekly, or Monthly, and pick which drives to include.
- Click OK.
Defrag From the Command Line
Right-click Start, open Terminal (Admin), and use one of these commands:
defrag C: /Aanalyzes the drive and reports fragmentation.defrag C: /Oruns the right optimization for the drive’s media type.defrag C: /Lruns a retrim on an SSD.defrag /C /Ooptimizes every drive.
If the PC is slow because memory is full, see how to free up and add RAM.
Troubleshooting
- Optimize is grayed out: The drive may be in use by another optimization, formatted with an unsupported file system, or a network drive. Close other disk tools and try again.
- Status says “Optimization not available”: This is normal for some external drives, virtual disks, and drives formatted as FAT32 in certain setups.
- It’s stuck at a percentage: Large hard drives can take hours. Leave it running, or restart and run it again.
- The PC is still slow: Fragmentation is rarely the main cause on modern PCs. Clearing temp files in Windows 11 and closing startup apps usually help more.
Still on an older PC? See how to defrag Windows 7.
Frequently Asked Questions
Does Windows 11 need defragging?
It needs optimization, but Windows handles it automatically each week. Manual runs mainly help hard drives that have had lots of large files added or deleted.
Does defragging speed up a computer?
On a hard drive with heavy fragmentation it can make file loading noticeably faster. On an SSD it makes no measurable difference, which is why Windows uses TRIM instead.
Is defragging the same as Disk Cleanup?
No. Disk Cleanup and Storage Sense delete unneeded files to free space. Defragmenting rearranges existing files so a hard drive can read them faster.
Can I turn off automatic defrag?
Yes, by clearing Run on a schedule in Change settings, but it’s best left on so SSDs keep getting TRIM.
Summary
- Search Start for defrag and open Defragment and Optimize Drives.
- Select the drive.
- Click Optimize.
- Leave the weekly schedule turned on.

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.