Technologytech

How To Enable Fstrim And Optimize SSD Lifespan On Linux After Install

how-to-enable-fstrim-and-optimize-ssd-lifespan-on-linux-after-install

Enable the systemd fstrim timer, which runs weekly by default and is the only safe, automatic method you need. Avoid the common mistake of putting `discard` in /etc/fstab, which slows down every delete operation and is almost never recommended.

Check if Linux fstrim is already active

Many modern Linux distributions enable the fstrim timer by default during installation. To verify, run systemctl status fstrim.timer. If the output shows "active (waiting)" and the timer is enabled, TRIM is already scheduled to run weekly. You can also check when it last ran with systemctl list-timers fstrim.timer; look for the "left" column showing time since the last trigger. If the timer is inactive or disabled, proceed to the next section.

Enable the weekly fstrim timer

This single step ensures your SSD maintains peak performance and longevity after you install Linux on SSD, without any extra configuration or risk. If the timer is not running, activate it with a single command: sudo systemctl enable --now fstrim.timer. This enables the timer to start on boot and immediately activates it for the current session. To test TRIM without waiting a week, run sudo fstrim -v / (replace `/` with your root mount point if different). This executes the same operation the timer would run, and prints the number of bytes trimmed. If it returns a value (even zero), the command works. If your system still fails to boot properly after these steps, the issue may be unrelated to TRIM, see why a Linux installed on SSD but boots to black screen after GRUB can occur. Scheduling is handled entirely by systemd; you never need to edit cron or add scripts.

Why you should not use the discard mount option

Adding `discard` to /etc/fstab forces the kernel to send a TRIM command for every single block that is freed, which creates a massive performance penalty on both SATA and NVMe drives. Each file deletion triggers an immediate I/O operation to the SSD, slowing down bulk operations like package updates or log rotation. Even on modern NVMe drives that support "queued trim," the continuous overhead is unnecessary because the weekly fstrim catches all freed blocks in one efficient pass. Online advice occasionally suggests `discard` for "better" TRIM, but it is almost never recommended for desktop or server workloads. If you format a solid state drive for Linux Mint, do not include the discard flag; use the timer instead. Similarly, when you configure SSD in BIOS, that only affects boot order and controller mode (AHCI or NVMe), not TRIM behavior; the discard mount option is a filesystem-level setting that operates independently.

Confirm your SSD supports trim

Even with the timer enabled, TRIM silently fails if the drive does not advertise support. Check with sudo lsblk --discard and look for the "DISC-GRAN" and "DISC-MAX" columns, if both show non-zero values, the drive supports TRIM. For NVMe drives, also run sudo nvme id-ctrl /dev/nvme0 | grep -i trim to see if the "ONCS" field includes "TRIM." SATA SSDs can be verified with sudo hdparm -I /dev/sda | grep -i trim; look for "Data Set Management TRIM supported." If these commands return nothing or zeros, your hardware does not support TRIM, and all software steps are silently ignored. In that case, consider a firmware update or replace the drive, as no amount of timer configuration will help.

Sources

The steps on this page were checked against the following documentation. Last verified 16 September 2026.

  1. Diehttps://linux.die.net/man/8/fstrim
  2. Archlinuxhttps://man.archlinux.org/man/fstrim.8.en
  3. Man7https://man7.org/linux/man-pages/man8/fstrim.8.html
  4. Geeksforgeekshttps://www.geeksforgeeks.org/techtips/how-to-use-the-fstrim-command-in-linux-for-ssd-optimization/
  5. Oneuptimehttps://oneuptime.com/blog/post/2026-03-02-how-to-enable-trim-for-ssd-performance-on-ubuntu/view
  6. Archlinuxhttps://wiki.archlinux.org/title/Solid_state_drive

About the author

A Green Tech Advocate Eco-Tech Enthusiast: Nestled in the bustling city of Toronto, Casey Tankersley stands as a beacon of hope for our planet's future.

View all 119 articles by Casey Tankersley  ·  Our editorial policy

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Stories