Let's say we have an ext4 filesystem image we dumped onto an SSD (with dd). After a few mounts we learn that we should use the discard flag to emit TRIM commands to the drive. As it is unclear whether the ext4 will trim all the free blocks the first time is mounted with discard, we do a manual online trimming:

fstrim /mount/point

Hopefully, this will not interact with the discard option. If we execute fstrim a second time in a row, it will report that no blocks were trimmed. The curious thing is, after rebooting the system, an additional fstrim run will again report that many blocks were trimmed (depending on free space).

Therefore, while it appears obvious that the Linux kernel does not keep track of the trimmed blocks in a persistent storage, the question is: does the SSD drive permanently remember the blocks that were trimmed?

In case it is helpful, the intention of all this is to reach a state similar than if the filesystem was freshly created and mounted with discard enabled from the beginning. So I was wondering if a single execution of fstrim was enough.

1 Answer 1


The SSD remembers which blocks are trimmed across reboots. Otherwise, the SSD would be very slow after each reboot until the OS managed to check the entire drive for trimmable blocks.

The OS, however, doesn't keep track of which blocks it has already told the SSD to TRIM across reboots.

A single invocation of fstrim should be sufficient.

  • Thanks. While it seems very logical I still haven't found any explicit mention about this trimming persistence on SSDs. Probably because it is tightly coupled to the page/block GC and the provisioning space reserved by the firmware.
    – C2H5OH
    Mar 19, 2013 at 15:02

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.