2

As to what TRIM does to SSDs, is the result the same as with writing zeros to free space? Eg: running cat /dev/zero > zero.file; rm zero.file on the drive?

1
  • 2
    No; Its not the same. TRIM indicates the data can be wiped. While writing all 0's results in the data being deleted its only being replaced not wiped. There is additional steps in this process but the data being wiped and replaced with 0's are NOT the same process.
    – Ramhound
    Apr 12, 2014 at 2:51

1 Answer 1

6

EDIT:

TRIM has already been explained way better than I did here:

What is TRIM exactly?

I found this link in the sidebar to this very question. So, should you need the dumbed-down version of an explanation of TRIM, i have provided it below c:


You have to understand how SSDs work to understand the answer to your question:

For technical reasons, writing and reading from an sd card is fast. The only operation that can be VERY slow is deleting something. Basically, writing and reading can be done in small parts, whereas to delete something, the controller has to apply a comparatively high voltage to the whole area where that something is in. That means it has to take all the data which are surrounding the deleted file, copy it to a different area on the disk, and then finally apply that "delete current" to the area. As you can imagine, that takes a long time. TRIM basically does this process in the background.

If you delete something on a modern OS, you don't really delete the space where the data are written. It just marks the space where the file was as empty by deleting the file's entry in the storage medium's file directory.

If you want to write new data to that file's spot, the area is still not ready on an SSD because deleting didn't really reset the storage to be ready to receive new data, it just marked it as deleted. If the controller would just wait until you need to write something and then start the whole moving data/really deleting process, it would slow down normal operations too much.

So, if you delete something, you can go on with your work, and if something needs to be written to the disk, the controller will just choose a different, already prepared area. Parrallel to this happening, TRIM performs the slow process of actually freeing that deleted file's space by moving the surrounding data and applying the delete voltage.

If you understood this process you can see why it is recommended to not fill SSDs to the brim with data, if you want good performance.

Now, if you write a file containing zeros to an SSD and delete it afterwards, you have basically done the worst thing you could possibly do to it's performance for while. At least until TRIM has done it's magic and reset all those sectors.

[DISCLAIMER] This is obviously a layman's view on the process, i have read all this when i researched SSDs many years ago, when they were new. It should sufficiently answer your question, though.

edit: spelling

1
  • No. Writing zeros has the same effect as TRIM, as SSD controllers are "smart enough" to regard zero as free space rather than data, just that writing zeros takes longer than TRIM. I have experienced performance improvement after writing zero on more than one SSD drives without TRIM feature.
    – robbie fan
    Aug 27, 2021 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.