7

After reading several articles I understand that Solid State Drives (SSDs) require special considerations such as partition alignment, choice of file system etc. TRIM support is needed to set up SSDs for optimal performance and my SSD support trim. I understand that adding “discard” to fstab is potentially dangerous but I'm no expert.

I have recently moved to elementary OS from Arch Linix where I simply enabled the fstrim.timer using systemctl however I need to understand how this is handled in freya.

2

Setting up a trim job on Freya

You can add the TRIM command to /etc/rc.local. Then this command will be executed automatically on system boot. This hardly slows the boot process down.

You can do that as follows:

  • Type in the terminal: sudo -i scratch-text-editor /etc/rc.local

  • Above the line exit 0 in that file, you now add the TRIM command fstrim for every automatically mounted EXT4 partition.

Note: not for partitions that aren't mounted by default! And also not for the swap partition, as that's already being trimmed automatically by the system by default, during the boot process.

Your rc.local should look like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
fstrim /
exit 0

If you have a separate home partition, then you add the following line as well, above exit 0: fstrim /home

Note: if you have a separate partition for /boot/efi, don't add a trim command line for that in rc.local. It's useless, as that partition is seldom being written to. And it may even cause malfunctions.

  • Save the modified file and close it.

  • Reboot your computer.

Disable the now useless weekly trim

sudo mv -v /etc/cron.weekly/fstrim /fstrim

With that command you've transferred the script file fstrim to the root directory, thus disabling it.

Source and other ways to optimize your SSD on elementary/ubuntu 14.04: Here

  • 1
    Why would you set up a trim at boot if there's already a weekly trim? And why would you move a file to the root directory? Talk about messy! Since this is a conffile, you can just remove it. If it wasn't, you'd need to use dpkg-divert. – Gilles 'SO- stop being evil' Aug 9 '15 at 15:34
  • 2
    @Gilles Weekly trims are useful if you are running "always on" servers but for laptops etc its important to set it up at boot (this is what I understand from the research on the subject). Instead of hitting on someone who was kind enough to respond with a comprehensive answer why not provide a detailed answer below with your method. That is what stack exchange is all about. – stephenmyall Aug 9 '15 at 19:05
  • @Gilles Thank you for your feedback, I was trying to provide undoability to the answer since people may want alternative methods, I would love to see your approach to the issue since I'm always looking forward to learn. – John Guerreiro Aug 9 '15 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.