Steps to add a daily SSD TRIM task to your Ubuntu system (tested with 12.04+) which will run via anacron
with logging of the trim process to /var/log/fstrimall.log
.
Note: if you have previously enabled TRIM support for your mounted drive(s) using the discard
option within /etc/fstab
you will want to remove this option and re-mount your drives first ($ mount -a
).
-
Install scripts
$ sudo wget \ https://gist.github.com/magnetikonline/8190599/raw/fstrimall.sh \ -O /etc/cron.daily/fstrimall $ sudo chmod a+x /etc/cron.daily/fstrimall $ sudo wget \ https://gist.github.com/magnetikonline/8190599/raw/fstrimall.logrotate \ -O /etc/logrotate.d/fstrimall
-
Optional: Edit
SSD_MOUNT_POINTS
section of/etc/cron.daily/fstrimall
, adding additional mount points for each individual SSD drive space separated - for example:SSD_MOUNT_POINTS="/ /myseconddrive /mythirddrive"
-
All done! Shortly after system boot, anacron should fire off the
/etc/cron.daily/fstrimall
task and TRIM each mounted SSD drive defined inSSD_MOUNT_POINTS
. Results will be logged to/var/log/fstrimall
. This log will be rotated weekly via the/etc/logrotate.d/fstrimall
logrotate task.