
With the release of Windows 10 version 2004, the Windows Defragger has become a mess as it starts to defrag SSD drives too often, perform trim on non-SSD drives, and forgets when it last optimized a drive.
Windows 10 includes an 'Automatic Maintenance' feature under Control Panel -> System and Security -> Security and Maintenance that performs various maintenance tasks on a scheduled basis. This maintenance includes checking drives to see if they need to be optimized (defragged/trimmed), checking for new updates, security scanning, and other diagnostics.

When optimizing drives, Windows 10 should record the last time a drive is optimized so that it does not defrag a drive too often.
As noted by the members at WilderSecurity, with the release of Windows 10 2004, the Optimize Drives feature is not correctly recording the last time a drive has been optimized.
Due to this, when you go back into the Windows Defragger, you will see that an SSD drive says it 'Needs Optimization' even though automatic maintenance was run this morning, as shown below.

In Windows 10 Insider Preview build 19551, Microsoft states that the issue has been fixed.
"Thank you for reporting that the Optimize Drives Control Panel was incorrectly showing that optimization hadn’t run on some devices. We’ve fixed it in this build," the release notes state.
Until that fix makes it into release builds, the 'forgetting' of when the drive was last optimized, cascades into other unwanted behavior as described below.
Defragging SSD drives too often
The general rule has always been that you should avoid defragging solid-state drives (SSDs) to prevent unnecessary wear and tear.
Microsoft developers, though, have stated in the past that there is some benefit to defragging a solid-state drive (SSD) that has become heavily fragmented, and due to this will defrag an SSD drive once a month.
"Actually Scott and Vadim are both wrong. Storage Optimizer will defrag an SSD once a month if volume snapshots are enabled. This is by design and necessary due to slow volsnap copy on write performance on fragmented SSD volumes."
Unfortunately, since the last optimization times are being forgotten, the Windows 10 automatic maintenance will cause an SSD drive to be defragged much more often than once a month if you commonly restart Windows.
These automatic drive optimizations are schedule for once a week, but can be configured to be done daily.
This issue was confirmed in numerous tests by BleepingComputer, where the automatic maintenance tool would perform a defrag of an SSD every time after a reboot. On the other hand, if you launch an optimization directly from the 'Optimize Drives' screen, an SSD drive will not be defragged and will only execute the Trim function.

You can see an part of a video showing the SSD being defragged by Windows 10 below.
This is a problem, as defragging an SSD too much is not good for the drive as it could prematurely reduce its lifespan.
Until this issue is fixed, if you use an SSD drive, it is suggested that you disable the automatic drive optimization of SSD drives in Windows 10.
To remove a drive from the Windows 10 automatic drive optimization, follow these steps:
- In the Start Menu, search for 'Defrag' and click on the 'Defragment and Optimize Drives' result when it appears.

- When the Optimize Drives screen opens, read through the list of drives and write down the drive letters for solid-state drives (SSD). Then click on 'Change Settings.'

- At the Optimize Drives settings screen, click on the 'Choose' button.

- You will now see a list of drives that will be automatically optimized on a regular schedule. Uncheck all SSD drives from the list and then press the OK button.

- You can now close the Optimize Drives screen.
All of your SSD drives should now be removed from automatic drive maintenance. When the issue is resolved in the future, you can add them back to automatic maintenance.
Trimming non-SSD drives
In addition to the issues described above, the Windows 10 defragger is trying to trim non-SSD drives.
The trim feature allows an operating system to tell an SSD drive when data is no longer being used and can be wiped on the drive.
As this is an SSD-specific feature, it is strange that the Windows 10 defragger is attempting to perform it on fixed disks when optimizing them.

This procedure fails, as non-SSD drives do not support the trim command.
Thx to Opera for the tip.
Update 6/14/20: Added clip showing the defragging of the C: SSD drive.





Comments
d0x360 - 4 years ago
<p>Wow this is some clickbait nonsense. Windows 10 NEVER defrags an SSD. It does however perform the Trim function which causes absolutely no harm even if you do it twice a day. Also windows defrag gets disabled completely (either manually) or by installing different defrag software.Anyways back to Windows... This tiny and easily fixed bug won't slow down a PC, hurt an SSD in anyway or even be seen by the user. I can't be the only one sick of seeing articles like this because the sites know that is what generates the most traffic besides GPU rumors. Enough!</p>
Lawrence Abrams - 4 years ago
Can you explain the video I just added to the article showing the C: SSD drive being defragmented?
This is a small portion of the entire video. The consolidation processes had many more phases.
The Trim function comes after the consolidation phase.
npcomplete - 4 years ago
But actual defragging only occurs with volume snapshots enabled right? Otherwise the optimize drive function only TRIMs the SSD. The volume snapshot should be disabled I believe it you disabled system restore points (recovery snapshots, VSS)
Lawrence Abrams - 4 years ago
That's what Microsoft says.
From our tests, the defragging does not work when you launch an optimization directly from the Optimize Drives screen. Only when you launch it via the Maintenance screen.
Control Panel -> System and Security -> Security and Maintenance
Raj09 - 4 years ago
There is this and the nvidia gpu 3000 rumours. The articles about how the gpu is going to be ugly looking made me laugh. Who has ever said "oh that's a nice looking gpu you got there big boy? "
eLPuSHeR - 4 years ago
"Wow this is some clickbait nonsense. Windows 10 NEVER defrags an SSD. It does however perform the Trim function which causes absolutely no harm even if you do it twice a day.
Also windows defrag gets disabled completely (either manually) or by installing different defrag software... Like defraggler which is free and the best defrag program out there.
Anyways back to Windows... This tiny and easily fixed bug won't slow down a PC, hurt an SSD in anyway or even be seen by the user. I can't be the only one sick of seeing articles like this because the sites know that is what generates the most traffic besides GPU rumors.
Enough! "
As far as I know you can have several defragmenters installed alongside Windows Defrag. It won't get it disabled. Also, defraggler has got some bugs (defragment free space creating more fragmentation) and haven't been updated in a long time. It now owned by AVAST.
the_moss_666 - 4 years ago
Triming non-SSD is actually not a bad idea. Recoverable deleted files are security risk. It's not as good (or paranoid?) as rewriting it multiple times by random data, place some dummy files on top and deleting it normally once more, but it's better than leave it as it is. There is one problem: it's unintentional feature.
herbman - 4 years ago
Thank you very much for reporting this Lawrence . This is clearly an issue that many didn't know about .
Winterland - 4 years ago
@Lawrence - you're a Saint. Not sure how and/or why you do all of this (the reporting, the Forums, etc.) but I am grateful. > bows <
noelprg4 - 4 years ago
the ms defrag problem affects both SSDs and HDDs, Lawrence.
noelprg4 - 4 years ago
defrag/optimization bug still NOT fixed with newly released KB4565503 security update in July.
guess it may get fixed somewhere in a 19041.4nn or higher build
CareyHolzman - 4 years ago
While this is interesting, I'd like to know if anyone has experienced anything tangible as a result. This appears to be about speculation and anxiety. You can probably defrag an SSD, over and over and over again, for many years before wearing out the write cycles (which seems to be the main concern.) If the write cycles are exhausted, the drive will still function in READ ONLY mode. It does not KILL the drive. I'm not aware of corporations with thousands of computers with SSDs being maintained automatically in Windows 10 suffering any losses, failures or productivity issues. Seems like an interesting bit of trivia, but not a real problem IMO. When someone can provide evidence of actual damage or loss, I'd love to hear about it. Until then, it sounds like a bunch of Technochondria (doctors can offer pills for that, ya know.) While this is a real issue, its not major or any big deal unless its ignore for many, many years.
CareyHolzman - 4 years ago
Another thing to consider is IF a defrag is done on ANY drive, the amount of time between defrags determines how much wear and tear is put on the drive. So, if you defrag a drive once a month, that's a big job. If you defrag 65 times a day, not much is done, since not much will have become fragmented. Again, this is just technochondria. Its not causing any problems and its not causing excessive wear and tear and no one has ever had a drive fail because of it.
NuAngel - 4 years ago
On a traditional, mechanical drive your theories are true. But on an SSD, excessive writes WILL cause the drive to wear out much faster than planned. With more and more and more computers going to SSD, these days, the timing for a bug like this is pretty nasty. No hasn't had a drive fail because of it "yet" - but the longer this drags on, the worse this problem is going to get..
For the record, I'm running Windows 10 Pro x640 2004 and even with the July updates installed, the bug still exists.
noelprg4 - 4 years ago
oh Lawrence
this defrag problem is possibly (and finally) fixed in the upcoming KB4571744 update for v2004 & v20H2:
https://blogs.windows.com/windows-insider/2020/08/26/announcing-windows-10-insider-preview-build-19042-487-20h2/
"We fixed an issue that causes the Optimize Drives dialog to incorrectly report that previously optimized drives need to be optimized again."
Hrdcpy - 4 years ago
My SSD completely failed one boot cycle after Windows update. Anyone else?
DocD - 3 years ago
It's now Aug 4, 2021. I am on Win 10 Pro, Version 21H1, Build 19043.1110 and the trim HDD error is still present. My system has neither KB4571744 nor KB4586853. I am getting regular Event errors on my HDD's (The operation requested is not supported by the hardware backing the volume. ). I have manually turned off ALL defragging by Windows. Since my drives are fairly large and the content DOES change frequently, defragging MIGHT be useful (I have 4 spinners) so I am going to do it using an app I have trusted for many years.. My SSD's will get a "trim" manually until this is REALLY fixed.