15

I read in one of the webupd8 articles that TRIM support, which was introduced in Ubuntu 14.04, by default only works for Intel and Samsung SSDs. What about other? I am using Dell XPS 13 Dev Edition laptop and the SSD is from a different manufacturer, so does TRIM work by default as well or I have to manually make a cron job file?

Braiam
  • 66,947
  • 30
  • 177
  • 264
Nikki Kononov
  • 1,300
  • 3
  • 15
  • 23

2 Answers2

21

Everything is already installed.

The command to activate trim 1 time:

sudo fstrim -v /

It will take a while and then show the results. Example:

sudo fstrim -v /
[sudo] password for rinzwind: 
/: 93184647168 bytes were trimmed

And it is set up by default to run once a week for -supported devices-:

$ locate fstrim
/etc/cron.weekly/fstrim
/sbin/fstrim

If you check the cron job it is all explained:

$ more /etc/cron.weekly/fstrim 
#!/bin/sh
# call fstrim-all to trim all mounted file systems which support it
set -e

# This only runs on Intel and Samsung SSDs by default, as some SSDs with faulty
# firmware may encounter data loss problems when running fstrim under high I/O
# load (e. g.  https://launchpad.net/bugs/1259829). You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives.
exec fstrim-all

If the manual method works, you can add --no-model-check to the command at the end (exec fstrim-all) for it to activate.


The link in the file is an interesting read. It also has a method to check if your disc is bugged. A lot of the cheaper SSDs are faulty and could destroy data.


And to top it off: this is a list of compatible hardware (PDF download) including SSDs.


There is another method where you add discard to your fstab for permanent trimming. Benchmarks (German) favor fstrim over discard.

terdon
  • 98,183
  • 15
  • 197
  • 293
Rinzwind
  • 293,910
  • 41
  • 570
  • 710
  • Awesome, thank you for the explanation. Now it's all clear. I'll mark the answer as the right one in a few minutes. Cheers. – Nikki Kononov Apr 17 '14 at 19:46
  • I didn't understand how to check if trim is working properly. Is there a script that checks it, or something else? – Dusan Milosevic May 27 '14 at 13:53
  • see the 1st command: `sudo fstrim -v /` this will error out if it is unsupported. – Rinzwind May 27 '14 at 13:55
  • According to bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/util-linux/… fstrim-all will also work for OCZ, Patriot and Sandisk and is automatically activated on Ubuntu 14.04 Trusty (See /etc/cron.weekly/fstrim) – Christian Benke Oct 07 '14 at 09:23
  • @ChristianBenke cool. I would assume more and more will be added :) Link is broken though ;) – Rinzwind Oct 07 '14 at 15:19
  • Ah, crap: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/util-linux/trusty/revision/103#debian/fstrim-all – Christian Benke Oct 07 '14 at 17:30
0

You can also force the TRIM (on filesystem like ext4/xfs) adding discard to the options of /etc/fstab entry. For example mine is:

/dev/sda3   /  ext4    errors=remount-ro,discard  0       1

If you use cryptsetup (for dmcrypt) you can also add discard in /etc/crypttab to force TRIM. Something like:

sda3_crypt UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx none luks,discard
Gelma
  • 107
  • 1
  • 3