Archives For November 30, 1999

How to Enable TRIM on SSD in Ubuntu Linux

Last updated: April 17, 2014

enable TRIM on SSD

Trim command (TRIM) helps keep your solid-state drive (SSD) at its full speed. If you find your SSD slowed down after a while of using, TRIM may help you make SSD always fast.

Because low-level operation of SSDs differs significantly from hard drives, the typical way in which operating systems handle operations like deletes and formats resulted in unanticipated progressive performance degradation of write operations on SSDs. Trimming enables the SSD to handle garbage collection overhead, which would otherwise significantly slow down future write operations to the involved blocks, in advance.

See more about TRIM on the Wiki page

UPDATE: Ubuntu 14.04 Trusty will have TRIM enabled by default.

To get started, press Ctrl+Alt+T on keyboard to open terminal. When it opens, follow steps below:

1. Check out if you have an SSD:

cat /sys/block/sda/queue/rotational

If you got 0 it’s a SSD. If the output was 1 it’s a HDD.

2. Even if you have an SSD not all of them support TRIM. To find out if yours does run:

sudo hdparm -I /dev/sda | grep "TRIM supported"

If what you get back is this:

Data Set Management TRIM supported

Then you are all good to go. If there’s no output, your SSD doesn’t support TRIM.

3. Next run:

sudo fstrim -v /

You should see an output that looks something like this:

/: 87781376 bytes were trimmed

4. If everything went OK it’s time to make a CRON job so fstrim run’s once a day.

To do this run:

gksudo gedit /etc/cron.daily/trim

Copy and paste below lines and save it.

#!/bin/sh
LOG=/var/log/trim.log
echo “*** $(date -R) ***” >> $LOG
fstrim -v / >> $LOG
fstrim -v /home >> $LOG

Finally make it executable:

sudo chmod +x /etc/cron.daily/trim

That’s it. You now have TRIM enabled.

via: pinguyos forum