Skip Navigation
22 comments
  • Trim support is standard. Any kernel released in the past 15 years or so will have trim support built in. So that's not something you should worry about.

    How trimming is triggered is another matter, and is distro dependent. On Arch and Debian at least there is a weekly systemd timer that runs the fstrim command on all trimmable filesystems. You can check it if's enabled with: systemctl list-unit-files fstrim.timer. I can't tell how other distributions handle that. On Debian derived ones, I imagine it's similar, on something like Slackware, which is systemd-less and more hands-off in its approach, you may have to schedule fstrim yourself, or run it manually occasionally.

    There is also the discard mount option that you can add in /etc/fstab, which enables automatic synchronous trimming every time blocks are deleted, but its use is discouraged because it carries a performance penalty.

    Hope that answers your question.

  • the Arch wiki has some info. Not too sure but i think enabling the systemd timer is enough.

  • not sure about manual but on ArchLinux and NixOS, TRIM can be automatically handled with BTRFS options:discard=async:

    • Enables discarding of freed file blocks in large chunks before queuing for TRIM.

    not sure if this helps but I'll be open sourcing my NixOS build and configuration.nix files in a bit(after school schedule stablizes)

  • Edited

    lsblk --discard to check support and non zero DISC returns mean TRIM supported. And then you need to add discard options to supported partitions in /etc/fstab. Then enable fstrim.timer with systemctl. And it will automatically run weekly. You can edit the run frequency by editing the fstrim.timer file.

    This is what I have done from reading Arch wiki. https://wiki.archlinux.org/title/Solid_state_drive#TRIM

    • You typically use either discard or the fstrim.timer, but not both at the same time.

      Using the discard option means that trims are being done on the fly every time blocks are deleted, using fstrim.timer means that trims are being done periodically. The former carries a performance penalty, so it's usually not recommended unless you need it (for example, if you regularly do huge amounts of writes and deletes on this drive).

      • Thanks for this. I got confused writhing this as I used discard on my previous install.

22 comments