To defragment a disk in Windows 10, click Start, type defrag, and open Defragment and Optimize Drives. Select the hard drive, click Analyze to see how fragmented it is, then click Optimize. Windows defragments hard disk drives (HDDs) and runs a TRIM optimization on solid state drives (SSDs) instead, which is what SSDs need. You don’t need to defrag an SSD.
Windows already optimizes drives automatically once a week by default. Here’s how to run it manually, check the schedule, and use the command line.
How to defragment a drive in Windows 10
- Click Start and type defrag.
- Click Defragment and Optimize Drives.
- Select the drive you want to optimize. Check the Media type column to see whether it’s a Hard disk drive or a Solid state drive.
- Click Analyze (available for hard drives) to check the fragmentation level.
- Click Optimize.

Defragmenting a large hard drive can take from a few minutes to several hours. You can keep using the PC, but it may be slower until it finishes.
HDD vs. SSD: what Optimize does
| Drive type | What Optimize does | Should you defrag? |
|---|---|---|
| Hard disk drive (HDD) | Rearranges scattered file pieces so the drive reads faster | Yes, when it’s more than about 10% fragmented |
| Solid state drive (SSD) | Sends TRIM commands so the SSD can manage free space | No traditional defrag needed. Let Windows handle it. |
How to change the automatic schedule
- In Optimize Drives, click Change settings under Scheduled optimization.
- Make sure Run on a schedule (recommended) is checked.
- Choose Daily, Weekly, or Monthly.
- Click Choose to pick which drives are included, then click OK.
How to defrag with Command Prompt
- Open Command Prompt as administrator.
- To analyze drive C, type
defrag C: /A. - To optimize it with progress shown, type
defrag C: /O /U /V. - To optimize all drives, type
defrag /C /O.
The /O switch chooses the right method for each drive type, so it’s safe for SSDs.
Tips before you defragment
- Leave at least 15% free space so Windows can move files around.
- Close large programs to let it run faster.
- Plug in your laptop, since defragmenting uses power.
- Don’t defrag a failing drive. If the drive makes clicking noises or has errors, back up your files first and run
chkdsk.
Frequently asked questions
How often should I defragment Windows 10?
The weekly automatic schedule is enough for most people. Run it manually only if a hard drive shows more than 10% fragmentation.
Does defragmenting delete files?
No. It only moves pieces of files closer together.
Is it bad to defrag an SSD?
A traditional defrag adds unnecessary wear to an SSD. Windows avoids this by running TRIM instead when you click Optimize.
Can I stop defragmenting halfway?
Yes. Click Stop in Optimize Drives. It’s safe to stop at any time.

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.