Press "Enter" to skip to content

TRIM, Linux, and your SSD

admin 0

First, since 2011 or so, TRIM has been enabled by default in the Linux Kernel but not what you’d call optimally. I don’t know the why of that so don’t ask! I have learned over the last few weeks that enabling TRIM using the “discard” option in /etc/fstab will end up significantly slowing your drive down. That option will make Linux use TRIM the same way Windows does. (which can cause your drive to slow down) TRIM tells the SSD drive to delete the information in the blocks and then write to them. In reality, there is no need to do this every time you write to the disk in Linux. (yes I know it is arguable, but this seems to be the consensus of the majority)

The smart thing to do is to create a ‘cron’ job to deal with TRIM, say, once a day, or once a week. You can do this with the ‘fstrim’ command. To see if your SSD drive even supports TRIM try the following in your terminal;

“sudo fstrim -v /”

If you see no error, and it tells you “/: 19 GiB (20374241280 bytes) trimmed” you’ll know you have a TRIM capable drive! (obviously your size will differ from mine probably). The above command is a way for you to manually TRIM your SSD drive whenever you like. The above command was to TRIM the ‘/’ (or root) partition or your SSD. You would do the same for home with;

“sudo fstrim -v /home”

The ‘cron’ job would look just a tiny bit different. Your not going to use the -v option. Here is a simple and effective way to create your own ‘cron’ job to TRIM your SSD drives;

“sudo medit /etc/cron.daily/fstrim”, and create a file with the following

fstrim / && fstrim /home

That takes care of the ‘/’ (or root) and ‘/home’ partitions. (a cron job for all the partitions on the SSD would be the smart thing to do)

Do not forget to go into the properties of the file you just created and mark it as ‘executable’.

You should now be get consistent performance from your SSD, as well as quite possibly extending it’s lifetime!

C'mon, you know you want to...

%d bloggers like this:
Skip to toolbar