How to activate Trim in our Ubuntu

How to activate Trim in our Ubuntu

Every day it is more common to find solid state hard drives in our equipment. This new type of hard disk gives us very high performance compared to its traditional brother, but it also requires a «special maintenance»Which is usually the downside of this hard drive. As with 64-bit systems, Ubuntu and the other Gnu / Linux distributions have utilities and tricks that allow you to manage these devices very well. One of these tools or utilities is called TRIM and it is the one that we are going to see in today's post.

What is TRIM?

TRIM is a system application that allows us to maintain the performance of our SSD hard drives as if it were the first day. Not all operating systems on the market bring the option of activating TRIM, although Ubuntu not only brings that possibility but also manages it automatically by choosing the file format. It is not only advisable to activate this option but almost mandatory if we do not want our SSD hard drive to have a short life.

How to activate TRIM?

To activate TRIM we have to meet the following requirements:

  • Ext4 or BTRFS file format. (By default Ubuntu installs Ext4)
  • A Kernel greater than 2.6.33 (the latest versions of Ubuntu greatly exceed it)
  • An SSD hard drive that supports TRIM (currently all SSD hard drives support this utility)

If we still doubt whether or not we are suitable for this tool, we open the terminal and write:

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

In "/ dev / sda" we can replace it with the SSD hard drive that we have, that is, if we have several hard drives, we look for the ssd, if not leaving it as is it will work. If we have it activated, a message like this or similar appears

Support TRIM dataset management (limit 8 blocks)

If the message does not appear, it is better to leave it since our computer does not support it, if it appears we continue.

Now we open the console again and write:

gksu gedit /etc/cron.daily/trim

It will open a file where we will paste the following text to the document:

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

We save it and now we check that TRIM works:

sudo fstrim -v /

If it works, a message like «8158715904 bytes were trimmed"If we do not have, we will try to restart the system or modify the last two lines of the text that we have pasted, replacing" / "and" / home "with the directories that are physically on the SSD hard drive.

If in the end it works for us, we will not only have lengthened the performance of our SSD hard drive but also its useful life, one of the main drawbacks that I see with SSD hard drives

More information - How to fit Ubuntu to the Netbook formatHow to partition hard drive in Ubuntu

Source and Image - Webupd8


A comment, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   leillo1975 said

    One question, in the weekly cron (gksudo gedit /etc/cron.weekly/fstrim
    ) of Ubuntu 14.10 I get this by default:

    #! / Bin / sh
    # trim all mounted file systems which support it
    / sbin / fstrim –all || true

    I understand that with this command you run it once a week.