Saturday, June 08, 2013

Tweaking your Linux for SSD

You'll need to tweaking your Linux setup a little SSDs being what they are. Before proceeding it's a good idea to backup your files and update the firmware. SSDs are new so there's still kinks in the controller firmware that need ironing out. SSD firmware aren't "good enough" that we can just neglect updating them. Ideally, you'll want to update the firmware as soon as you bought it.

Use noatime

Everytime you access a file on Linux, the access time (atime) gets updated. For SSDs this is bad since it increases wear on the NAND cells even if you don't change the contents of the file.

Open up /etc/fstab using your favorite text editor and add noatime as a mount option for partitions on your SSD.

Here's the line from my /etc/fstab for reference.

UUID=ae539cc9-cc39-440b-9093-c406b98f5f13 /               ext4    noatime,errors=remount-ro 0       1

TRIM support

Linux swap partitions do trimming automatically so nothing to do there. For / and any other partitions you may have in there you'll want to use ext4 or btrfs since these are the only filesystems that currently support TRIM.

Also, use the fstrim command to do TRIM on boot. You'll need to edit /etc/rc.local for this. Add fstrim -v for every partition on your SSD above the exit 0 line. It should look something like this.

fstrim -v /
exit 0

Your SSD should get TRIM'd on every boot. You'll hardly notice the slowdown.

Tweaking swappiness

Edit /etc/sysctl.conf to set the kernel to prefer using RAM over swap. You'll want to add the following lines to the end of the file.


That's about it. If you want to get even more aggressive with SSD tweaking then head over to this article where I sourced the above tips.

Now go out and enjoy the speed.