I am upgrading my system (2011 MacBook Pro) by installing an SSD. I was wondering if there is any sort of configuration in Ubuntu that will help prolong the life of the drive?

I'm not even sure if there is any, I just seem to recall doing something similar on windows a couple of years ago.

I am using version 14.04

  • I'll provide an answer, but it will take some time to write, so wait .. and yes you can enable TRIM on Linux, in fact it is ON by default for some brands, from 14.10 I believe Jun 16, 2015 at 17:23

2 Answers 2

  1. Change SATA configuration to AHCI in BIOS

  2. Over-provisioning

    it's used for prolonging life of SSD, by leaving some part of your SSD unformatted/ unallocated - 7% should do, but some people go to 28%. Considering the fact, that SSD still aren't "cheap" and disk space is priceless, I don't use this technique at all.

  3. Format as EXT4 (but I guess that's common sense, also relevant only if you are going to do clean install)

  4. sudo nano /etc/rc.local

    this method will perform TRIM on every boot, but it won't slow it down, trust me, I'm using this setup myself. Put fstrim before line exit 0. That must be done for every automaticaly mounted EXT4 partition. Example bellow:

    fstrim / 
    exit 0

    Also you can adapt the code to make logs about TRIM

    fstrim -v / >>$LOG 
    echo “Time: $(date)” >>$LOG
    exit 0

    If you have separate home partition, you need to add fstrim /home etc.If you have separate /boot/efi, don't TRIM this partition, also never run TRIM on SWAP.

    save and reboot

  5. Disable the unnecessary weekly cron job for TRIM, as it will be performed on every boot

    sudo mv -v /etc/cron.weekly/fstrim /etc_cron.weekly_fstrim.bak

    you will basically move this command elsewhere, so it won't be performed

  1. Decrease SWAPiness

    • check your swappiness level, by default it's 60:

      cat /proc/sys/vm/swappiness
    • sudo nano /etc/sysctl.conf after it opens, put these line to the end of file:

      # Sharply reduce swap inclination

  2. Reboot

That's all I did, but there are other approaches, for example with cron job, which I've disabled, or by discard ...

  • If somebody could please edit code I have included (which should be "standalone"), because indentation by 4 spaces don't work for me in many cases....I have no idea what I'm doing wrong Jun 16, 2015 at 18:31
  • @A.B. So it's by 8 spaces? Oh, ok...good to know and thank you. Jun 16, 2015 at 18:48
  • Perfect, yeah I'll be doing a clean install, these steps are invaluable it's a TB SSD and it wasn't cheap.
    – Alec.
    Jun 16, 2015 at 20:52

This topic is here to read AS thread too :


You can try different things with hdparm too, but mostly this is not necessary today any more compared to days where SSD were something more exotic.

This second link is oder for more details simply read man hdparm :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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