Really is that so...did you test this like I did...easy to copy and paste from somewhere.
What's this...could this be freed space on my SSD surely not...
View attachment 19599
Alternatively, we can run a TRIM manually by using the fstrim command:
$ sudo fstrim -v /
/: 22.2 GiB (23802130432 bytes) trimmed
The output is the amount of freed space. Also, the -v option provides a more detailed and informative output.
From this article...https://www.baeldung.com/linux/trim-ssd
People can say whatever they like but it's the proof that counts more than quotes. View attachment 19600
People can say whatever they like but it's the proof that counts more than quotes.
To which proof are you referring? The article or the output of fstrim?
Proof: run
df -ha /
before and after fstrim
:
Code:
user@host:~$ df -ha /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgubuntu-root 914G 254G 614G 30% /
user@host:~$ df -a /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vgubuntu-root 958137496 266222520 643170528 30% /
user@host:~$ sudo fstrim -v /
[sudo] password for user:
/: 10.8 GiB (11602771968 bytes) trimmed
user@host:~$ df -ha /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgubuntu-root 914G 254G 614G 30% /
user@host:~$ df -a /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vgubuntu-root 958137496 266222544 643170504 30% /
As you can see, before running fstrim the used blocks were
266222520
and after 266222544
- during the time I executed the commands the OS saved logfiles, and I assume the browser saved some tmpfiles or so, which took up additional space. No space was freed.The output of the fstrim command states
/: 10.8 GiB (11602771968 bytes) trimmed
. trimmed != made available for writing, but made available for FAST writing without having to be trimmed first.man fstrim
: "fstrim is used on a mounted filesystem to discard (or "trim") blocks which are not in use by the filesystem. This is useful for solid-state drives (SSDs) and thinly-provisioned storage."which btw is the same as
mount -o discard
- just not on every delete action but periodically (weekly), from man mount
:
Code:
If set, causes discard/TRIM commands to be issued to the block device when blocks are freed
I quickly flew over this article but haven't found a sentence that states that the space is made available. Can you point out to which section you were referring?
From this article: "TRIM improves the SSD’s performance by reducing the amount of data that needs to be written and overwritten. When the SSD receives a write request, it can quickly find an empty block and write the data there without having to erase an old block first. This reduces the write amplification, which is the ratio of the actual amount of data written to the SSD and the amount of data requested by the host. Notably, a lower write amplification means a faster and more efficient SSD."
I'm a bit unhappy with this sentence:
TRIM improves the SSD’s performance by reducing the amount of data that needs to be written and overwritten
With NAND flash you need to first "clear" a block before you can write to it again. This is what trim does, instead of waiting for your FS to request writing to the block the next time, which would then have the SSD trigger that action when you might need fast write speed.
Btw, the article was last updated December 28, 2023 but recommends to setup a cronjob for it, which, due to systemd timers replacing cronjobs in modern linux distros, is not a good approach. Additionally (at least in debian and ubuntu, correct me if this is different in RedHat based distros and others) there is a systemd timer by default.
From the linked article: 4.1. Checking Existing Mount Options - "If the discard option is in the output, it usually means that TRIM is on for the ext4 file system."
Thats a bit misleading. The discard mount option calls trim right after a file is deleted, which can negatively impact performance on very busy servers, as deleting a file will take up additional ressources in a time where i might not want that. It might make sense to do this only at night.
From the article: "In particular, we need to add the discard option to the mount options of our file system."
The article states at the end: "However, this approach to enabling TRIM can make deletion much slower and increase CPU usage." which is correct and worth noting.