Defrag

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.

Security and Maintenance screen
Security and Maintenance screen

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.

Not remembering when drives were optimized
Not remembering when drives were optimized

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.

Defragging an SSD drive
Defragging an SSD drive

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:

  1. In the Start Menu, search for 'Defrag' and click on the 'Defragment and Optimize Drives' result when it appears.

    Search start menu

  2. 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.'

    Click on Change Settings

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

    Click on Choose

  4. 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.

    Uncheck SSD drives

  5. 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.

Trying to trim a non-SSD drive
Trying to trim a non-SSD drive

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.

Related Articles:

Windows 10 KB5046714 update fixes bug preventing app uninstalls

Windows 10 KB5046613 update released with fixes for printer bugs

Microsoft warns it lost some customer's security logs for a month

Windows 10 KB5044273 update released with 9 fixes, security updates

New Windows 10 0x80073CFA fix requires installing WinAppSDK 3 times