Ubuntu 14.04 - TRIM Your SSD

Whilst watching htop when installing wine, I noticed a lot of disk wait time, which I thought was odd because I'm running a Samsung 830 SSD on Ubuntu 14.04. (If you're thinking about getting an SSD, I currently recommend the 840 EVO.) One of the "big features" of Ubuntu 14.04 was supposedly TRIM support, enabled by default, which should keep the SSD In fairly prime condition. It turns out that this is only "half the story".



Samsung And Intel Only

"Only Intel and Samsung SSDs will have TRIM enabled by default in Ubuntu 14.04 because some cheap SSDs can even brick themselves when running TRIM. This doesn't mean TRIM should only be used with Samsung and Intel SSDs, but to avoid running into issues, this is the only option for now." [ Source ]

Default Weekly Anacron TRIM

There is a script at

/etc/cron.weekly/fstrim
which executes the TRIM weekly with Anacron.

For those not familiar with Anacron, it's very much like the cron service, a utility that runs a task/script at a scheduled time or event (such as a reboot), except that with anacron, if the event was missed due to the computer being off at the time, anacron will trigger the script/task next time the computer is started up. The folders located at

/etc/cron.hourly/
,
/etc/cron.daily/, /etc/cron.weekly/
, and
/etc/cron.monthly/
Are folders that accept scripts which will be executed by the anacron service as root at the relevant time schedule (hourly, daily, weekly, monthly).

Using Anacron can be dangerous because if you miss the scheduled event several times (e.g. you just came back from a long holiday), it will cause the script/task to be triggered multiple times upon the next reboot (once for each missed scheduled occurance), so the script should handle this gracefully!

Manually Running TRIM

I wasn't prepared to wait until the weekly trigger for my SSD to be trimmed, and wanted to be sure that the SSD is getting trimmed, so I manually ran the TRIM with the following command:

sudo fstrim -v /

References

No comments:

Post a Comment