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:
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.