Tweaks to Make After Installing an SSD Drive

Five tweaks to make to optimize your Linux computer for a solid-state drive

  1. Enable the TRIM command to clean up garbage on the drive. You can do this as long as the Linux kernel is 2.6.33 or later, and you are use ext4 or other TRIM-friendly file systems.
  2. Stop the system from recording every time files are accessed. By default Linux writes this information onto the drive for each file your system touches – every time it touches a file!
  3. Use RAM instead of the SSD drive for storing temp and log files.
  4. Swap more to RAM instead of the SSD.
  5. Prioritize “reads” over “writes”.

Enable TRIM and reduce writes to the hard drive

The first three tweaks are made by editing /etc/fstab. You use these flags to reduce SSD writes:
noatime,nodiratime,discard

  1. Edit the fstab file as an administrator. On Mint, I open a terminal window and type the command:
    sudo gedit /etc/fstab
  2. Edit the file to add the flags to the line that represents your SSD drive. It may be a line that begins with ‘UUID’ or with ‘/dev/sda1’ or something similar, depending on your Linux distribution. Here is how my file looks with the old line commented out and a new one added with the additional flags:
    ###################################################################
    # / was on /dev/sda1 during installation
    # use these flags to reduce SSD writes: noatime,nodiratime,discard
    # noatime and nodiratime flags turns off writing "last access time"
    # discard enables TRIM as long as kernel >= 2.6.33
    # UUID=59d0f1dd-30b1-43c4-8d67-977a7130e353 / ext4 discard,errors=remount-ro 0 1
    UUID=59d0f1dd-30b1-43c4-8d67-977a7130e353 / ext4
    noatime,nodiratime,discard,errors=remount-ro 0 1

  3. While you have the fstab file open for editing, add the following 4 lines so that you use RAM instead of your SSD for temp and log files: ###################################################################
    # Added 4 lines to use RAM instead of SSD for temp and log files
    tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
    tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0
    tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
    tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

  4. Now save the file and restart the computer to mount the SSD drive with your changes.

Reduce swappiness

Add these two lines to /etc/sysctl.conf to make the system swap more to RAM.###################################################################
# Manual settings - these settings are to optimize for SSD drive
# Ref: https://wiki.archlinux.org/index.php/Solid_State_Drives
#
vm.swappiness=1
vm.vfs_cache_pressure=50
#

Prioritize “reads” over “writes”

Edit your GRUB boot loader’s configuration file to organize the I/O scheduler to maximize performance:

  1. Run this command to check the currently active scheduler: cat /sys/block/sda/queue/scheduler After installing my SSD, mine reads: noop [deadline] cfq The active scheduler appears in brackets.
    noop‘ is essentially no scheduler at all. It uses a first-in, first-out (FIFO) prioritization.
    deadline‘ prioritizes reads over writes. This is what you want for SSD drives.
    cfq‘ completely fair queuing is the default and is designed for traditional rotating drives.

    Before you make the change to grub, ensure that you use the command above to determine which scheduler is active. On my Mint 14 64-bit system, the active scheduler was already set to “deadline” even though the grub file does not reflect the edits I’ll detail below. Mint 14 appears to have detected the presence of the new SSD on its own and automatically switched itself to use “deadline”.
  2. For Ubuntu and other distributions using GRUB2: sudo gedit /etc/default/grub
  3. Add ‘deadline’ to the GRUB_CMDLINE_LINUX_DEFAULT line like this: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline"
  4. Then to finalize the changes, run ‘sudo update-grub2‘ or ‘sudo update-grub‘. You’ll find the correct command to use referenced in the comments at the top of the grub file itself.

With increased RAM, a solid-state drive and these 5 tweaks, my two year old HP dm4 has become a fast booting, high-performance dream machine.

Credits

Leave a Reply

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