Check what kind of drive you have before you defragment it: Windows 10’s Optimize Drives tool defragments hard disk drives, but on a solid state drive it runs a retrim, which Microsoft describes as telling the drive where it can safely do its cleanup work. To run it, search the taskbar for defrag, open Defragment and Optimize Drives, select the drive, then select Optimize.
Windows 10 reached end of support on October 14, 2025. On Windows 11, see defragmenting a drive in Windows 11.
Before you start
- Know your drive type. The drive list in Optimize Drives shows whether each drive is a hard disk or a solid state drive. To learn more about the SSD in your PC, checking SSD size in Windows 10 shows where Windows lists its capacity and model. The type matters because Microsoft’s drive optimization page describes two jobs: hard drives are defragmented, and SSDs are “trimmed,” which tells the drive where it can safely do its cleanup work. Microsoft sums it up as “It’s all optimization”: Windows picks the right job for each drive type, so leave SSDs in the automatic schedule. According to Microsoft’s command reference, the scheduled task also gives SSDs a traditional optimization and a retrim once a month.
- Free up some space. Microsoft says a volume needs at least 15% free space for a full defragmentation. With less, defrag only partly finishes. Checking storage on Windows 10 shows how much room you have and what to remove.
- Fix disk errors first. Windows will not defragment a volume that is marked dirty (flagged for possible file system errors). Run CHKDSK on it first; using CHKDSK in Windows 10 walks through it.
- Plug in a laptop. A long defragmentation on battery drains it quickly, and the automatic weekly run skips laptops that are on battery power.
Defragment a drive with Optimize Drives
- Select the search box on the taskbar and type defrag.
- Select Defragment and Optimize Drives in the results.
- Select the drive you want to work with. The list also shows when each drive was last optimized and its current status.
- For a hard disk drive, select Analyze if you want to see how fragmented it is first. The status column updates when the check finishes.
- Select Optimize.

How long it takes depends on the drive’s size, how full it is and how fragmented it was, so a large, busy hard drive can take a long time. You can keep working, though the PC may feel slower until it finishes. When the status no longer says the drive needs optimization, you are done. Defragmenting moves pieces of files closer together; it does not delete anything.
If you need to stop a run in the window, select the drive and look for the button that takes the place of Optimize while it runs. Microsoft does not document that control, so check the label on your screen; for the command, Microsoft documents Ctrl+C (see the command section below).
Fragmentation happens because Windows writes a file into whatever free space is available, so a file that grows or is saved over time can end up in many scattered pieces. A hard disk has to move its read head to each piece, which slows it down.
Change the automatic schedule
By default, Windows optimizes drives once a week, so most people never need to run it by hand. To check or change that:
- Open Defragment and Optimize Drives.
- Under Scheduled optimization, select Change Settings.
- Make sure the schedule is turned on, then choose Daily, Weekly or Monthly.
- Use the drives option to pick which drives the schedule includes, then confirm.
The same window has an option to raise the priority if optimization misses three runs in a row. Microsoft notes that the scheduled task will not wake a sleeping PC and will not run on battery power, so a laptop that is usually asleep or unplugged at the scheduled time can fall behind. An external hard drive is only optimized when it is plugged in at the time, so run it manually now and then.
Defragment from Command Prompt
The defrag command does the same work from a command line and is handy for checking several drives at once. You need administrator rights: search for cmd, right-click Command Prompt, and choose Run as administrator.
| Command | What it does |
|---|---|
defrag C: /A |
Analyzes drive C and reports fragmentation without changing anything |
defrag C: /O /U /V |
Runs the proper optimization for the drive’s media type, shows progress and prints detailed statistics |
defrag /C /O |
Optimizes all volumes, each with the right method |
defrag C: /L |
Runs a retrim on an SSD |
defrag /C /H /O |
Optimizes all volumes at normal priority instead of the default low priority, so it finishes sooner but slows other work more |
defrag C: /A /V > report.txt |
Saves the analysis to a text file |
Press Ctrl+C to stop a command that is running. Microsoft’s /O switch description, “the proper optimization for each media type,” is the same job the scheduled task runs. The full switch list is in Microsoft’s defrag command reference. In PowerShell, Optimize-Volume -DriveLetter C also picks the right job by drive type.
If a drive is missing or will not optimize
Microsoft lists the volumes defrag cannot process:
- Network drives and CD or DVD drives.
- Volumes that use a file system other than NTFS, ReFS, FAT or FAT32.
- Locked volumes, which another program has open for exclusive use. Close the program that is using the drive and try again.
- Dirty volumes. Run
chkdskon the drive, then optimize again.
If a hard drive finishes but still shows some fragmentation, check the free space: under 15% free, Windows can only partly defragment it.
Defragmenting questions
How often should I defragment by hand?
Usually never. With the weekly schedule turned on, Windows keeps hard drives in order on its own. A manual run makes sense after the PC has been off or on battery for weeks, after copying or deleting a large amount of data on a hard drive, or for an external drive.
I am moving Windows to an SSD. Should I defragment first?
It is not required, but checking the old drive for errors and clearing space first makes the copy smaller and faster. Moving Windows to a new SSD covers the clone and clean-install options.
Is the tool the same on older Windows?
Windows 7 uses an older version of the tool with a different layout; defragmenting in Windows 7 shows that version.
For most Windows 10 PCs, the best next step is just to open Optimize Drives, confirm the schedule is on, and let Windows handle the rest.

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.