Linux SSD trim / fstrim options - partition shows full but isn't
Status: Site Admin
Joined: 26 Sep 2003
Posts: 4060
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Here's some notes on how to setup stuff for trim. I hit this issue when my SSD / partition reported itself full with df -hT, but was actually only using 14 out of about 55 GiB.

I had followed some older how-to's that said add 'discard' to the partition mount in /etc/fstab, this is apparently not correct in general, so remove that first, then reboot to make sure the partition is mounted as expected.

Or do instead, along with removing the discard from /etc/fstab mount line:
:: Code ::
mount -o remount,nodiscard /home
mount -o remount,nodiscard /

Note that you can in fact remount / using the above command!

Read more about trim on the Arch Linux wiki:

To trim manually, do:
:: Code ::
fstrim -va

if you only have an SSD, that will trim all mounted partitions.

To trim only one, put the mount point, root in this case:
:: Code ::
fstrim -v /
/: 43.2 GiB (46426198016 bytes) trimmed

As you can see here, mounting / with discard never even worked as suggested, and was simply not the right thing to do, as damentz notes below.

For systemd users, you can enable systemd's scheduled trim with:
:: Code ::
systemctl enable --now fstrim.timer

Damentz of Liquorix explained it this way:

:: Quote ::
Q: can you run fstrim on a mounted partition?
A: yes, you're supposed to in fact. The filesystem has information about free inodes, and that's fed to fstrim.
You can't actually run fstrim on an unmounted volume.

fstrim.timer runs fstrim periodically, usually about once a week on all your ssds, it's built into systemd.

Q: I thought you could put the trim stuff into fstab [aka, discard]
A: No, never do that, that kills write performance. that's called discard. In fact, on both xfs and ext4, they disabled discard by default. There's a few golden SSDs out there that don't hurt performance with discard, but the majority behave very badly. I'm guessing enterprise, where you can't risk running fstrim on a schedule, you need 100% low latency responsiveness at all time.

Back to top
Display posts from previous:   

All times are GMT - 8 Hours