Jump to content

Automatic TRIM Support On Ubuntu

Opcode

Ubuntu TRIM Tool

 

Alright, we all know how beneficial TRIM is to maintaining performance of an SSD. The problem is the Linux kernel doesn't have it enabled by default. In this guide I will show you how to setup your Ubuntu based distro to automatically TRIM.

 


Step 1 - Checking For Trim Support


 

Run the following command in a terminal.

sudo fstrim -v /

If you get the following message then your SSD is supported with TRIM (it may take a minute).

 

97khPnH.png

 

If you do not you will need to exit this tutorial and figure out why as to your SSD isn't supported.

 


Step 2 - Creating Cron Job


 

Run the following command to open up the nano editor with the given target file.

sudo nano /etc/cron.daily/fstrim

Then key (or paste) in the following shell script.

#!/bin/shfstrim /

After that is done, press CTRL + O to save the file (it will prompt to save as file name, just hit enter) and then CTRL + X to exit nano editor.

 

Lastly we need to chmod the file permissions.

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

This will ensure the file is in fact executable.

 


Step 3 - Verify (Optional)


 

At this time automatic trim support is setup. If you wish to double check that everything setup properly you can do the following.

stat -c %a /etc/cron.daily/fstrim

If the command returns 755 then everything's setup correctly.

 

And there you have it, the system will run a TRIM cron job daily (I believe at 6:25 AM) to ensure your SSD maintains peek performance.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

I thought the newest version of Ubuntu (truast and utopic) has fstrim by default?

Kernel has supported it for a while, tho Ubuntu decided to not enable it as it's "too resource hungry" in their own opinion. So the next best thing you can do is create a daily cron job to trim your drive.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×