Trim SSD – preventative cleaning on a solid-state drive. Does TRIM or Deallocate work on your SSD? Why TRIM is useful for SSD drives

First in Windows Server, and now Windows 10 has a modern REFS (Resilient File System) file system, in which you can format hard disks computer or disk spaces created by system tools.

This article is about what the REFS file system is, its differences from NTFS and possible applications for the average home user.

In addition to features related to maintaining data integrity on disks, REFS has the following main differences from the NTFS file system:

  • Typically better performance, especially when using Storage Spaces.
  • The theoretical volume size is 262144 exabytes (versus 16 for NTFS).
  • No file path limit of 255 characters (in REFS - 32768 characters).
  • REFS does not support DOS file names (i.e. access to the folder C:\Program Files\ on the way C:\progra~1\ it won't work). In NTFS, this feature was retained for compatibility with older software.
  • REFS does not support compression, additional attributes, or encryption using the file system (NTFS has this, but it works for REFS).

At the moment, it is not possible to format a system disk in REFS, the function is available only for non-system disks (not supported for removable disks), as well as for Storage Spaces, and, perhaps, only the last option can be truly useful for regular user, who is concerned about the safety of data.

Please note that after formatting a disk in the REFS file system, part of the space on it will immediately be occupied by control data: for example, for an empty 10 GB disk this is about 700 MB.

It's possible that REFS could become the primary file system in Windows in the future, but that hasn't happened at the moment. Official information on the file system on the Microsoft website:

This article describes the ATA TRIM command, which is used to increase write speed on SSD drive And.

The use of the ATA TRIM command does not happen automatically in all cases; in some situations, the execution of this command on the OS side must be explicitly enabled.

First you need to make sure that your SSD drive supports this command. However, all new disks support it. This check can be done with any modern disk program. For example, on Linux this can be done using console command:

hdparm -I /dev/sda | grep -i trim

Where sda your SSD drive. The command output should contain the line "TRIM supported".

How TRIM works

One of the main functions of any file system is storing a list of disk sectors in which a particular file is recorded. That is, each file has a list of disk sectors associated with it.

When you delete a file on an SSD disk, the operating system sends the TRIM command to the SSD disk controller and along with it a list of sectors that can be cleared. The controller writes these sectors to the queue of its garbage collector routine. And this subroutine processes all sectors from the list.

The garbage collector runs when the disk is idle. That is, when the operating system does not send requests to read or write data. Therefore, some time passes from the moment the TRIM command is received until these sectors are actually deleted.

If there are many sectors in the trimerization queue, cleaning them may take a long time. For example, if you quickly format an entire partition, TRIM of that size can take a long time.

However, there is no need to sit and wait for the process to end. Even if the disk is turned off, queue processing will resume after it is turned on.

When TRIM doesn't work!

  • The TRIM function does not work if the SSD is connected via USB.
  • The TRIM function does not work for partitions with the FAT32 file system.
  • The TRIM function does not work yet for a large number file systems(for example Ext2).
  • The TRIM feature does not work when you delete an entire partition, even if the file system supports TRIM and this option is enabled.

When TRIM Should Work

  • Linux with kernel starting from 2.6.33 and Ext4 file system.
  • Windows 7, 8 and 10 and NTFS file system.

In either of these options, the TRIM command is sent only after files have been deleted. Or separately, forcefully for all free space, if the OS supports this option.

Enabling TRIM on Linux

Note. In Ubuntu, starting from version 14.04, you do not need to do anything additional. Everything works out of the box.

Firstly, to use TRIM, the file system must be ext4.

Secondly, enabling the TRIM command is specified in the mount option for the ext4 partition in the fstab file. This is specifically an option. discard.

In addition, for a partition on an SSD disk, you can add the noatime (or realtime) and nodiratime options - this reduces the write load; access dates for files and folders will not be updated.

You can also add the commit option and specify a value of, say, 60 seconds - deferred write operations will be performed on the partition once every 60 seconds. But this option can only be added if you have a UPS (UPS), or on a laptop!

So an example line fstab might look like this:

UUID=aeade6fd-2b24-4e59-bc8c / ext4 noatime,discard,errors=remount-ro,commit=60 0 1

On Linux, you can also run the TRIM command manually:

sudo fstrim / -v

This example applies the command to the root file system. If there are multiple ext4 partitions, then this command must be executed for each such partition.

Checking and enabling TRIM on Windows 7, 8 or 10

First you need to open the console (Command Prompt) with administrator rights. Start menu - Programs - Accessories - Command line. Right mouse button - Run as Administrator.

fsutil behavior query disabledeletenotify

If the command output is disabledeletenotify=1, then the TRIM command is disabled. You can enable it with the command:

fsutil behavior set disabledeletenotify 0

Don't get confused! Zero - TRIM on, one - TRIM off.

How to TRIM on an NTFS partition

If you have an operating system Windows 7, 8 or 10, then you don't have to do anything. Just check that the TRIM function is enabled. Next, Windows will automatically send the TRIM command during the following disk operations:

  • Deleting file(s).
  • Quick formatting of an NTFS partition (disk).

In Windows 8 and 10, you can manually issue the TRIM command for an entire NTFS partition (drive). In the disk properties, on the "Service" tab, you need to open the Disk Optimizer. This is the new name for Windows Defragmenter.

In Disk Optimizer, the "Optimize Disk" command will be available for NTFS partitions on an SSD disk. Running this command causes Windows to send the SSD drive a TRIM command for all free blocks on that drive. That is, “trimming” of all free space on the NTFS partition (disk) is performed.

In Windows 7, 8 and 10, you can “trimize” an entire NTFS partition (disk). To do this, you need to quickly format this partition (disk). However, it is important to understand that this will destroy all data on the partition.

In the latest (2015, 2016) versions of the ntfs-3g driver (ntfs driver for Linux), the TRIM function has been added. Now you can trim an NTFS partition from Linux. Command in terminal:

fstrim -v /media/ntfs/

where /media/ntfs/ is the mounted NTFS partition.

How to TRIM on Windows XP and Vista

Neither Windows XP nor Vista support TRIM. If you need to “trim” an SSD drive that is used in these OSs, then there are the following options:

What is TRIM (garbage collection)

SSD drives have an important difference from HDDs that affects the write speed. In HDD, recording is performed “on top” of old data. Disk blocks that previously contained data and then that data was deleted are simply marked as free. And when you need to write, the HDD controller immediately writes to these free blocks.

When using flash memory, blocks that previously contained some information must be cleared before being written. This leads to the fact that when writing to previously used blocks, the writing speed drops significantly, because the controller needs to prepare them for writing (clear them).

The problem is that OS traditionally do not work with the file system in such a way that deleting files clears the contents of blocks on the disk. After all, on HDD drives there was no need for this.

Therefore, when using SSD drives, the effect of “performance degradation” occurs. When the disk is new and all flash memory blocks are clean, then the write speed is very high, as specified. But after the disk is completely full and after that some of the files are deleted, re-entry will occur at a lower speed. Because the disk controller will have to clear the flash memory blocks before writing new data there.

The drop in write speed to reused flash memory blocks can be very high. Up to values ​​close to the recording speed of HDD disks. When testing SSD drives, they often even conduct a special test to reduce the write speed of reusable blocks.

To combat this phenomenon, the new operating systems have added the TRIM disk ATA command. The file system driver, when deleting a file, sends the TRIM command to the SSD disk controller. With this command, the SSD disk controller clears freed flash memory blocks, but does so in background, in between read and write operations.

Using this command returns full write speed to reused flash memory blocks. However, not all operating systems support this command. But only relatively recent versions:

  • Linux kernel since version 2.6.33.
  • Windows 7, 8 and 10
  • Mac OS X starting from version 10.6.6 (but for this version you need to install an update).

Until now, the popular WIndows XP (as well as Vista) do not support this command.

A workaround for older OSes is to use third-party programs. For example, this could be the hdparm program (version 9.17 and higher) or branded programs SSD drive manufacturer, for example Intel SSD Toolbox.

There are two models of SSD drives in which the degradation of the speed of reused blocks is less pronounced than others:

  • Plextor M5 pro (discontinued).
  • Plextor M5S (discontinued).
  • Intel 545s
  • Samsung 860 EVO

The firmware of such disks can partially clear unused blocks without the TRIM command. Restoring the recording speed to full rated recording speed.

In 2019, many models of SSD drives can independently “collect garbage”. You can find out more precisely about a specific model by reading test reviews. In serious Internet publications, among other tests, they also test the ability of a disk to independently clear blocks.

The TRIM command may not work if the motherboard's SATA controller was set to IDE mode (for compatibility with an older OS or program).

The TRIM command is most often disabled when using a RAID array.

Recovering Deleted Data

If you are using TRIM, about recovery deleted files you can forget. If you delete a file, its data on the SSD will be destroyed.

Impact of TRIM on recording speed

It is important to understand that using or not using the TRIM function does not directly affect the write speed of an SSD drive. Only one factor affects this speed - the presence of a sufficient number of free flash memory blocks. That is, such blocks that have been cleared by the disk controller and are ready for new data to be written to them.

In other words, the recording speed depends on the amount of free space on the disk. If your disk is almost completely full, the writing speed will drop even if you use TRIM. And vice versa, if you have 20-30% of the disk capacity left unallocated disk space, then you can do without using TRIM. The disk controller will use the unused capacity for partitions to equalize the write speed.

But reserving free place It is important to understand that this must be done on a new SSD drive before using it. If you delete already existing section. Or reduce the size of the existing size, the flash memory blocks occupied by this partition will not be cleared. They will remain occupied until you use that free space again.

If you want to reserve free space on a fully partitioned SSD disk, then you need to run a forced TRIM command on the entire partition and only then delete the partition (or reduce its size).

Some manufacturers' utilities, such as Samsung's Magician program, allow you to allocate a portion of the SSD drive's capacity for use by the drive controller (write cache and wear leveling). In this case, such allocated space will not be available to operating systems - they will “see” less disk capacity.

TRIM is an important function (command) that can significantly extend the life of your SSD. If the TRIM function is enabled and working, then when files are deleted from the SSD, data from unused memory cells is completely cleared. When the user simply deletes data, the cells are simply marked as unused, but in fact remain filled.

Typically, TRIM support for SSDs is enabled by default on Windows operating systems (including Windows 7/8/10). But sometimes it happens that for one reason or another this option may not be activated. Therefore, to maintain performance and extend the life of your SSD, it is still better to check if the TRIM function is working.

How to do this, as well as how to enable TRIM in Windows if the function does not work, read this short instruction.

How to check if the TRIM command is enabled (using Windows 10 as an example)


In our example (see screenshot above), the received report shows that the TRIM command is enabled and used - the value is 0 opposite NTFS DisableDeleteNotify.

If the number was "1", it would mean that the TRIM command is disabled.

How to enable TRIM in Windows 10, 8 and Windows 7

If the TRIM function is disabled, then when using an SSD drive, it is highly recommended to activate it.

Method one:


Second way:

If “Disk Optimization” determines the media type correctly, but in fact TRIM support is disabled, then the TRIM command can be enabled manually:


How to disable TRIM

If you want to disable TRIM support, then:

  • Run command line Windows as administrator;
  • Run the command fsutil behavior set disabledeletenotify NTFS 1 .

Conclusion

All of the above applies to operating Windows systems 10, 8 and Windows 7, where TRIM support is generally enabled by default, but in some cases user intervention is still required to enable this option. As for older operating systems from Microsoft (Windows XP and Vista), there is no built-in support for TRIM, but it can be enabled using various programs, for example, old Samsung versions Magician, Intel SSD Toolbox, etc.

In fact, today we will talk not only about drives that have been used for some time, because the problem of low performance can affect even an SSD just brought from the store. Of course, you can't fool physics - over time, all solid-state drives will lose performance. But the reason for this may not only be the problem of the SSD itself. Ensuring competent interaction of components and software in the system is not an entirely simple task for ordinary users who do not want (or who simply do not need) to understand the topic at least a little and listen to the advice of people competent in this regard. For some, it’s easier to reinstall the operating system or add some dubious “tweakers” to the list of applications used. But think about it - for example, deleting a file, which is simple from our point of view, consists of a fairly large number of stages in which several participants are involved at once. And, if at least one of them performed the task incorrectly, then this affects the performance of the disk. What are these stages? By whom or what are they performed? How to ensure stable operation? We’ll figure all this out today. Simple and clear so that everyone can understand it. And then it will become clear that treating the symptoms of poor SSD performance will not help.

Seven troubles - one deallocate

Many have heard about the TRIM team. Those same cherished four letters that raise many questions among the average user. TRIM is one of the ATA commands sent by the operating system to notify the solid-state drive that data from the disk has been deleted by the user and occupied physical cells can be freed. It is worth mentioning separately about SSDs with an NVMe interface - these drives have a different set of commands for operation, but an analogue of the ATA TRIM command also exists there - it is called Deallocate and, accordingly, is identical. Therefore, further when we mention TRIM we will also mean Deallocate. Why are we talking about all this? It is precisely the problems with executing these commands that in the vast majority of cases are the reason for the low performance of drives. Of course, we will not leave other problems aside either, but everything has its time.

The moment you delete data from your drive, an entry in the main table of the file system is actually deleted. That is, the data itself remains in place, but the area is marked for deletion. The “cleaning of cells” itself occurs at a certain time, for example, when the drive is idle while you go for tea. In this way, manufacturers achieve reduced memory wear and increase the performance of their drives in certain scenarios. The controller is responsible for cleaning these cells by executing the TRIM command. By the way, after its execution, data recovery is almost impossible.

More recently, we have, which is similar to TRIM, but affects not only the main cells, but also service areas, returning the drive to its completely original state. Let us remind you that Secure Erase can be performed on a drive only without a file system and under certain conditions. And TRIM technology precisely requires an operating system with all the attendant requirements.

Let’s explain it on our fingers, there are just 20 of them...

When you create a file, the operating system sends a write command to the address of a specific logical block. When you delete data from a disk, those blocks are marked as free.
In this case, the data will remain on the disk until the controller wants to overwrite it.

Before us is a part of memory in which there are files A and B of different sizes, occupying, respectively, a different number of blocks. First we delete file B, and then write file C to our disk. To visualize the situation when TRIM does not work, we will add a simple illustration in which the following states are indicated:

  1. Availability of files A and B.
  2. A certain period of inactivity. Note that the data blocks marked for cleaning remain with the data in them.
  3. Write file C, but first delete file B from the cells.
For example, if you imagine (just imagine, yes) that a data block in the form of a square is 1 MB, then at stage 4 the controller first clears two data blocks with file B marked for deletion and only then writes file C. If a couple of megabytes of space - There are still little things, but if you actively work with the drive, such blocks can add up to gigabytes, which will already noticeably affect the time it takes to complete write operations.

Now what happens if TRIM works. Again in stages:

  1. Availability of files A and B.
  2. Deleting file B with our own hands.
  3. A certain period of inactivity during which blocks marked for deletion with file B are cleared.
  4. Writing file C without any delays to the area where file B was.

That is, the logic of work is completely different. Let's repeat what we've covered - at the moment we delete file B, the TRIM command is sent, and since the SSD is idle quite often, it happily deletes unnecessary blocks almost immediately. And the moment we want to write file C, it is immediately written to disk, and does not wait until the garbage blocks are cleared for it.

TRIM, do you even exist? And, if so, do you work?

You can find out whether an SSD supports the TRIM command using a fairly large amount of freely distributed software. Let's take CrystalDiskInfo for example:

But showing support is not work. First, let's go through situations when TRIM needs to be launched in a tricky way or this command does not work at all. Of course, the situation may change over time, but for now things are as follows:

  1. Standard Windows drivers cannot perform TRIM on RAID arrays. Depending on the system and type of RAID array, a driver from Intel called Rapid Storage may solve the problem. Arrays 0 and 1 are supported with the Enterprise driver.
  2. TRIM support in Windows begins with operating system version number 7. Vista and, especially, XP do not support TRIM at the OS level. Of course, this problem is solved by a third party software, but everything here is at your own peril and risk - we cannot and will not recommend this.
  3. The Deallocate (TRIM for NVMe SSD) command is only supported with Windows 8 and later.
  4. TRIM does not work on virtual disks.
  5. TRIM only works in AHCI mode.
  6. TRIM does not work when connecting the drive via USB adapters.
  7. TRIM does not work with the FAT32 (or more “shaggy”) file system.
Now let's check - does TRIM work in the system?

To begin with, let’s try to find out this directly from the operating system. In a command line or PowerShell running as Administrator, enter the command “fsutil behavior query disabledeletenotify” without quotes and look at the result. If the output shows “0”, then this is good – TRIM is working. If “1”, then the TRIM functionality is not available. That's right: zero is an enabled command, 1 is a disabled command.

For example, you can use the easy-to-use trimcheck program from Vladimir Panteleev. The program works in two stages, between which a few seconds or tens of minutes can pass - it all depends on the specifics of the specific SSD model. The utility writes data to disk and marks the addresses of the virtual blocks in which they are located. It saves these addresses in a JSON file in its folder, after which it deletes the data, which causes the TRIM command to be sent. The utility checks whether previously recorded data is located at the saved addresses. Their absence means that the controller took note of the TRIM commands and deleted the data. If TRIM is running, the message will be as follows:

Otherwise the inscription will read TRIM appears to be NOT WORKING. Actually, if you receive a message about inoperability, then run the command “fsutil behavior set disabledeletenotify 0” without quotes in a command line or PowerShell running as Administrator. The TRIM function, if all conditions are met (supported OS, implementation in SSD, etc.), should turn on and work. If this does not happen, and all the requirements are met, then you will have to think about replacing the drive.

Problems, problems instead of lunch

The most common problem is inheritance. Of course, we are talking about Windows up to version 8. For example, when the user puts in the old SSD systems or move from HDD to SSD without changing BIOS settings (if necessary) or even by cloning partitions or the entire disk. We remind you that TRIM is only available in AHCI mode. For example, many motherboards can operate in two modes: AHCI and IDE. Accordingly, if the SSD is connected to such a board in IDE mode, then TRIM will not work. Simply having AHCI mode does not solve the problem - Windows will install drivers according to the selected IDE. It would seem that the situation may occur rarely, but in reality it does not. If with BIOS settings You are not friends, then you should at least check the operating mode. This can be done in Device Manager in the “IDE ATA/ATAPI Controllers” section:

Remember that just like that after Windows installations switching the operating mode from IDE to AHCI (and vice versa) without additional manipulations will not work - the operating system simply will not boot. Solutions to this problem exist (even from Microsoft itself), but they are not worth recommending. Registry settings need to be changed, adding the required driver and readiness to reinstall the OS in case of failure.

As for Linux systems, a prerequisite, in addition to the hardware component, is the ext4 file system. Enabling TRIM is indicated by the discard option in the fstab file. Additional useful options for the partition will be noatime (realtime or nodiratime), which will reduce recording by disabling updating the time of last access to files and directories. The TRIM command itself is launched using the fstrim program - “fstrim / -v” without quotes and with root rights.

Let's also remember about Secure Erase. You can restore performance with this function. But it’s unlikely to last long. Especially if you quickly fill up your drive with new data. So it will work as a temporary solution, but it will always remain temporary.

Let’s also add about SLC caching, which is quite often used in many SSD drives without being tied to an interface. The low recording speed of a large number of files (or large files) after a certain threshold is not a problem, but a feature of the work. The essence of caching is that the data being written first ends up in a special memory area, and only then is written to the main memory in the background. When the allocated high-speed memory runs out, data begins to be written directly to memory at a noticeably reduced speed - from 50 to 150 MB/s. This is a completely normal mode of operation of drives with SLC cache, so nothing can be done here at all.

What's good and what's bad?

If the TRIM function worked from the very beginning, then by itself it cannot go anywhere. But it’s a completely different matter if you are interested in various kinds of tweakers, third-party drivers or firmware, as well as assemblies of operating systems that are supposedly improved. All these programs and assemblies can only do harm when we are talking about Windows 8 and, especially Windows 10 - everything in these OSs is thought out as it should. In the “seven” they can help in some way, but this is rather an exception to the many problems that they can bring.

Separately, I need to say a few words about NVMe drives and drivers for them. When purchasing a high-speed SSD, the stated speed indicators obtained in benchmarks should be reflected in your eyes. This is often true, for example, with Kingston drives. Set it and forget it, as they say, enjoying its high speeds. But with SSDs from other manufacturers, this may not always be the case, which will obviously frustrate anyone. Here it is no longer the lack of Deallocate that is the reason for insufficient performance, but the standard NVMe driver. Yes, yes, when purchasing an NVMe SSD from some manufacturers, you must go to its website and download the appropriate driver - the difference with the standard one can exceed twofold!

Now, it seems, that’s all.

As it turned out, not everything was as scary as it looked at first glance. The user is required to follow just a few recommendations so that the system works correctly and enjoys the performance of the solid-state drive for a long time. Let us repeat them finally - a clean distribution of the operating system, up-to-date drivers and firmware from the manufacturer, as well as the absence of third-party system “tuners”, which, according to their developers, increase performance by 146%. If the problem is not hardware, then you will not have any complaints about the disk for the entire life of your system. So there will be no long conclusion or verbiage - everything that needs to be said has already been said. Capacity SSDs for you, their high speeds and stable operation!

For more information about products

Today we will talk about the so-called TRIM function and its connection with SSD solid-state drives.

The TRIM function is needed to avoid performance degradation in, and has appeared since Windows 7. Now I will explain in more detail how TRIM works and how to check if it is enabled on the computer.

What is TRIM?

First, let's look at the HDD (regular HDD with moving parts). Most file systems are now designed specifically for HDDs and there is the following type of data processing: we have a file that we decide to write to the hard drive, the system writes data about the file to a cluster stored on the disk, and the coordinates of this file are recorded in an address table called MFT(Master File Table). To access this data, the system takes coordinates from the MFT. When we delete a file, the data is deleted from the MFT, but not erased from the cell (cluster). After we decide to write other files to the disk, maybe new ones, the data is written to cells on top of the deleted ones.

This type of recording to a drive is in no way suitable for SSDs, since they are developed using a different technology. The drives use flash memory and writing data over deleted data is not allowed here. In other words, unnecessary actions would be performed that would load the SSD drive: first, data is copied from the cluster to the cache, then the cluster is cleared, and recording begins new information, on top of the old one. If there is nothing in the cell, that is, it is empty, then only recording occurs. It is clear that when writing information to an empty cell, this happens many times faster than unnecessary actions, such as overwriting and replacing old data. Under such circumstances, the SSD drive would lose its original speed.

Fortunately, we have TRIM technology that solves this problem. In simple words, as soon as the data from the MFT is erased, it will be deleted from the cells, and then new data will be written.

By the way, there are also older SSD drives that do not support TRIM; they were simply created for older operating systems that did not have this function.

TRIM requires the following conditions to work:

  • Availability of drives that support TRIM;
  • An OS that supports TRIM. This is in Windows 7;

You also need to have the Microsoft Storage driver installed, but usually it is installed automatically, unless, of course, the SATA controller supports AHCI mode. Also TRIM will not work if the function is active and if you are using .

TRIM works not only on Windows, but also on Linux. You must have kernel version 2.6.33 or higher.

To check the activity of the AHCI mode for the SATA controller, you need to go to the device manager and expand the tab "IDE ATA/ATAPI Controllers", or something similar.

How to check if the TRIM function is enabled, and if not, how to enable it?

First, we will check the activity of this function. Open the command line as administrator and enter the command there:

fsutil behavior query DisableDeleteNotify


If the value is 0, then the TRIM function is enabled, and if it is 1, then it is disabled.

Do we enable the TRIM function?

Yes, everything is very simple here, we again open the command line as administrator and enter the following command:

fsutil behavior query|set DisableDeleteNotify = 0

Now you can check the functionality of the function again.

I think we can end this article here, if you have an SSD drive, then it’s a good idea to know the definition of TRIM, especially before purchasing a drive you should make sure that this function is supported, otherwise the service life of the disk without it will decrease sharply, and the speed will be so to yourself.

Publications on the topic