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.
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.
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.
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 |
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.
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.
When Optimize Won’t Run or Gets Stuck
- 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.
Related: increase virtual memory in Windows 11.

Kermit Matthews runs Live2Tech from just outside Philadelphia. He is an IT specialist with over 20 years of experience, from a university help desk to small-business IT, IT management and his own consulting practice, and has written tech guides full time since 2020. Steps are checked against the current software on a real device or the maker’s official documentation. More about Kermit.