SSD trim frequency in Ubuntu

I’m not sure if the same question applies for windows and other linux distros, i am trying to learn trim frequency in Ubuntu when we are dealing with large files like plots.

as far as i understand, trim is not enabled by default in Ubuntu and we enable it with “discard” option while mounting.

After that, trim service runs once a week (default schedule) to trim drives with mounted discard option.

at that point two questions in my mind,

  • What sould be the trim frequency → once a week is enough?

  • Can we run trim service (function) while plotting?


1 Like

i watched that video, in the end it refers trimming but i could not catch trim frequency and do it while plotting or not. Maybe i missed. In which minutes in video does he answer my questions or i can watch again :slight_smile:

By default trim is enabled in ubuntu. It’s done once per week which is usually more than enough.
Discard on the other hand does isse a trim command every time a block is freed.
This can but does not have to cause performance issues because the storage is overwritten immediately.
Personally, i would not worry too much about trimming. Modern ssds usually have a hand full of spare blocks availablle and trimming happens there in the background

1 Like

In the video (at the end) he suggests turning the discard option on. Ubuntu doesn’t default discard to on - instead it defaults to a systemd timer that runs TRIM once a week. You can turn discard on for the filesystem in your fstab (and then disable the now-redundant systemd timer).

Another option would be to tweak the systemd timer to run fstrim more requently. On 20.04 (and probably other versions), you’ll want to edit /lib/systemd/system/fstrim.timer, changing OnCalendar=weekly => OnCalendar=daily (or hourly). Then run sudo systemctl daemon-reload to reload the systemd config.

I haven’t noticed any issues with TRIM running (either via discard being turned on, nor by having run frequently via the timer) while plotting is happening.


Thank you for that summary!

As an aside, I dislike the way people post videos as “answers”… at least pull the key info out in a text reply in addition to the video because we can read 100x faster than we can watch and process a video…


I agree 100%. As a long-time software developer, the trend towards video tutorials for what used to be written blog content is a huge pet peeve of mine. I know lots of people prefer technical content in video form, but I think they’re insane masochists.


thank you for the summary!

1 Like

This is where I pull out the why-not-both-girl.gif … you can do both video and a text summary. That way everyone gets what they need.

Annnnnnnnd I can continue to ignore the video entirely and process the text at 100x the speed :wink: