SSD Optimizations in Linux

Have you ever heard of an SSD-friendly Linux distribution? Have you seen a Linux installer that will give you an option to mount /tmp in RAM or to do any other SSD related optimisations? If you were to try the latest Ubuntu / Fedora / OpenSUSE, you will end up with misaligned disk, disabled TRIM, unoptimised partition type. This is a serious pitfall that knocks Linux down a notch in comparison with Windows. If Linux wants to become competitive in the tablet and TV market, it will have to adapt to the hardware that is included in those devices. The days of IDE hard disks are not quite over, and it might take another decade for IDEs to completely disappear, but we can not disregard the fact that 100% of mobile devices and a good portion of laptops use flash, flash based memory, or SSD drives as their primary storage.

There are a some fundamental differences between IDEs and SSDs, that make the default Linux installation unacceptable. Your flash-based drive will wear out faster due to unnecessary disk writes, and you are not going to experience the full potential increase in speed due to unoptimised partitioning or incorrect disk scheduler. Use this guide to make your Linux installation SSD-friendly, until these major flaws are fixed.

  • Disk Alignment - Due to the fact that SSD reads and writes chunks of data that are 4k in size, make sure that your partitions begin and end along 4096 bytes boundaries. Boot from a LiveCD and in GParted verify that the first sector of your partition is divisible by 4096. Otherwise "resize/move" a partition by modifying the "Free Space Preceding", making sure to round to nearest "MiB".
  • Enable TRIM - Edit /etc/fstab to include "discard" option for all SSD mounts.
  • Disable SWAP - Do not create SWAP partition or if you already have created it, edit /etc/rc.local to include echo 1 > /proc/sys/vm/swappiness
  • SATA AHCI mode - Make sure that in BIOS the SATA ports are functioning in AHCI and not in IDE mode.
  • Disable access-time writes - Mounting SSD file-systems so that file access times are not written back to disk. Edit /etc/fstab and add "noatime" option to all SSD mounts.
  • Disk Scheduler - Using "noop" or "deadline" disk scheduler leads to faster disk writes. Run cat /sys/block/sda/queue/scheduler to find out the scheduler currently in use. Then add echo noop > /sys/block/sda/queue/scheduler to the /etc/rc.local file.
  • Temporary Folder - Mounting the "/tmp" folder in RAM will minimise unneeded disk writes. Edit /etc/fstab file and add tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
  • Disable Journaling - You can still use EXT4 but disable the journaling option to minimise disk writes. Run tune2fs -O ^has_journal /dev/sda1 && sudo e2fsck -f /dev/sda1. After reboot verify that it worked with "dmesg | grep EXT4".
  • Firefox Cache Folder - In order to prevent Firefox from constantly accessing your hard disk we would have to use /tmp folder mounted in RAM as the default file caching location. This can be accomplished by going to "about:config" in the browser address bar and adding a new String entry labelled "browser.cache.disk.parent_directory" with "/tmp" value.
  • Back to main index