Trim functionality on SSDs

Hi,

I have realized, or think I figured it out ;), that Rockstor is not doing any TRIM on mounted SSDs. Nor by using discard as a mount optione (perhaps not the best option anyhow) or using the fstrim.timer option (or a cron job) to trim unused data from SSDs and keep them live longer.

Can this be implemented, for me, I am running rockstor on a small SSD which makes the system just horrible fast :smiley: and applications like plex which huge databases more than usable :slight_smile:
Enable TRIM would be a great idea on one or the other way.

Some documentation I found, but there is for sure more out there anyhow
http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/
https://devhen.org/enable-trim-support-for-ssds-on-linux/
https://wiki.archlinux.org/index.php/Solid_State_Drives
https://wiki.archlinux.org/index.php/Btrfs#SSD_TRIM

I resolved it in the meantime using a weekly cronjob and a script found at on of the articles mentioned above

create file and open in nano

nano /etc/cron.weekly/fstrim

copy and paste the script

#!/bin/sh
LOG=/var/log/fstrim.log
echo [ $(date) ] $(/sbin/fstrim -v / 2>&1) >> $LOG
echo [ $(date) ] $(/sbin/fstrim -v /home 2>&1) >> $LOG

set the executable flag

chmod +x /etc/cron.weekly/fstrim

do a testrun

/etc/cron.weekly/fstrim

open the log file

cat /var/log/fstrim.log
[ Mon Sep 14 13:17:49 CEST 2015 ] /: 67.8 GiB (72746291200 bytes) trimmed
[ Mon Sep 14 13:19:10 CEST 2015 ] /home: 67.8 GiB (72749588480 bytes) trimmed

I just followed your instructions and they worked fine (except for a spelling error in the testrun part).

On my system I got the following in the log:

[ Mon Sep 14 14:33:30 CEST 2015 ] /: 2.5 GiB (2630717440 bytes) trimmed
[ Mon Sep 14 14:33:33 CEST 2015 ] /home: 2.5 GiB (2626510848 bytes) trimmed

This is on a small 16Gb SSD. But it does seem that Rockstor does not trim as default (which I think it should).

great :smile:

fixed it :slight_smile: