How to Test Your SSD Speed with TRIM

The TRIM command enables you to test the speed of a solid-state drive and enhance its performance. Learn more about the command and how to run it.


5 minutes

Solid-state drives (SSDs) are very useful storage devices. They can bring old computers back to life and keep them out of landfills. SSDs) can also reduce the total cost of ownership (TCO) of storage solutions for organizations. That doesn’t mean that SSDs don’t need maintenance occasionally. You might start to notice that the speed of your SSDs might seemingly degrade after a while. So, let’s discuss how you can test SSD speed and make it faster.

Specifically, you can enhance the performance of an SSD by manually running the TRIM command on it.

What is a TRIM Command for an SSD?

Solid-state storage devices live and die by their controllers (SSDs typically fail due to controller failures before the memory modules wear out). Drive controllers in SSDs do an excellent job of keeping data flowing and organized within those SSDs. They’re not perfect, though.

Unlike traditional spinning disk hard drives, SSDs go through a garbage collection process. During the lifespan of an SSD, the controller will flush unneeded data from drives and re-allocate those storage blocks for use again. This process is different from a filesystem marking storage blocks as used or available. This garbage collection process occurs at a hardware level (unlike a filesystem that is strictly a software-level component). We can initiate this garbage collection process through ATA commands.

Previously, we had complete control over storage devices. We could issue ATA commands to storage controllers that would perform very specific functions on a hard drive. Those days are long gone, though. Today, drive controllers abstract those ATA commands from the physical hard drive hardware.

We can still issue ATA commands, but drive controllers perform those actual functions. Therefore, issuing an ATA command doesn’t mean that command will be executed on a hard drive.

The ATA command we can use to initiate that garbage collection process on an SSD is the TRIM command. The TRIM command may go by various names depending on your SSD manufacturer or software you’re using. Whatever it may be called, that TRIM command functions the same way.

When a user deletes data from an SSD storage device, data is technically not removed from that SSD. Instead, the location where that data was stored is marked as usable again, though the information is still physically stored on the device. If the SSD needs to write data to one of these locations, and the storage block it’s trying to write to isn’t physically empty, the drive controller on the SSD must first remove that data before new data can be saved to that location. This causes latency in the drive write operation since the SSD now needs to perform multiple additional operations.

The TRIM command tells the SSD to purge unneeded data when the computer is idle (or technically, when the SSD is idle). This operation keeps the SSD running at peak performance. That TRIM command doesn’t always run, though.

For instance, in a server environment, there may not be idle time for SSD storage solutions. A NAS or SAN can be serving data to hundreds or thousands of people at once. There isn’t any time to idle.

Even in consumer environments, an SSD may not initiate the TRIM command properly. For example, years ago, one of the Samsung EVO SATA-based 2.5” SSDs had a known issue running the TRIM command properly. As a result, Samsung issued firmware updates, as well as stand-alone software utilities to fix that issue. Though that example is an edge case, the lesson remains that we should manually force the TRIM command to run occasionally.

How Can You Force an SSD to Run TRIM?

Forcing the Trim command is a two-step operation. Technically, forcing the TRIM instructions to run on an SSD is a single command, but you’ll want to do some housekeeping first.

There are a couple of ways to do this housekeeping. First, you could use a drive diagnostic program like SpinRite or Window’s built-in Check Disk utility. Both tools will scan storage drives for bad sectors. 

We need to force the SSD to examine each drive sector to ensure that any sectors that need garbage collection are appropriately marked. Any application that can scan a drive for bad sectors will work, but ensure that they’re designed to take it easy on SSDs. For example, both SpinRite and Check Disk are intended not to tax SSDs while scanning for bad sectors.

Pro tip: The best and cheapest option to perform housekeeping on your SSD is to first run Check Disk followed by Defrag in Windows. Check Disk will force the SSD to properly mark sectors for garbage collection while fixing any potential errors on your drive. Defrag can also force an SSD to mark sectors for garbage collection with the added benefit of aligning files for faster sequential read operations. Though Windows primarily handles both tasks on its own, running both tools manually is a good idea before running TRIM on your SSD.

After preparing your drive for running TRIM, launch PowerShell in Windows as an administrator (right-click and select Run as Administrator). Then, enter this command:

Optimize-Volume -DriveLetter YourDriveLetter -ReTrim -Verbose

Make sure you change YourDriveLetter to the drive designation of your SSD. Depending on the size and status of your drive, the TRIM command shouldn’t take long to run.

By running Check Disk, then Defrag, and finally manually running the TRIM command, you’ll test your SSD with software and make it faster.

Recap

You can make your SSD faster with software. This is more or less returning your SSD to its original speed and ensuring the drive is entirely operational. Though there are many different methods that you can use to enhance the speed of your drive through software, one of the primary ways you can achieve this is by issuing the TRIM command to your drive controller. Before manually issuing the TRIM command to your SSD through PowerShell, make sure to run both Check Disk and Windows Defrag on your drive first. Those applications will perform tests on your drive for issues and prepare it for running TRIM.