Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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 '13 at 15:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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