Step one, Purchase a good SSD.
This may seem obvious, but it's really not as easy as it sounds. I poured over benchmarks and reviews before purchasing my SSD's, and I really came to two conclusions. Either buy a Samsung drive or an Intel drive. They really seem(ed) to me to have the best balance of reliability, speed, support and staying power.
I settled on Samsung 830's, right before the 840's came out, and I'm really happy with my choice considering that the 830's have MLC memory and the 840's have TLC. If you want to understand more about that, Uncle Google is your friend.
Step two, install an SSD friendly Linux.
Ok, this is pretty easy now, any up-to-date distro will do. But, for example, Debian stable doesn't support Trim, so if you are a Debian user, you'll either want to install a backported kernel, or run Testing. If my understanding is correct, Ubuntu 10.04 and CentOS/Scientific Linux/RHEL have had TRIM support backported into their older kernels.
Step three, tweak your SSD friendly Linux into submission.
By default, even SSD friendly Linux distros aren't all that friendly to SSD's. You have to make them play nice. Below are the steps I followed to do this.
Change your default Scheduler
/etc/default/gruband adding an option to the
GRUB_CMDLINE_LINUX_DEFAULTline. This is how mine looks:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
sudo update-grubto update Grub with those changes.
/etc/fstabto enable TRIM
/etc/fstabfile and add the word
discardto your list of mount options. I usually go ahead and add
noatimeas well to disable writing of last access time information to reduce those writes as well. Here is an example of a line in my
UUID=7d552b7d-3f05-461e-a85f-153100136552 / ext4 discard,noatime,errors=remount-ro 0 1
fstabyou may want to mount
tmpand any other temp directories which do not contain data needed after reboot to RAM.
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0
I've since discovered from Linux Kernel developer Theodore Ts'o that it is far better to execute fstrim manually than to use the 'discard' mount flag.
I created the following script:
And created a cron job to execute this script each morning. I also abandoned having tmpfs in RAM as well.
vm.swappinessto tune down how aggressively memory pages are swapped to disk.
If you have a lot of physical memory, you may rarely swap anyway, but I like to set my
10to further reduce how likely it is that I will swap. Linux moves memory pages that have not been accessed for some time to the swap space even if there is enough free memory available. By changing the percentage in /proc/sys/vm/swappiness you can control the swapping behavior. A high swappiness value means that the kernel will be more likely to unmap mapped pages. A low swappiness value means the opposite, the kernel will be less likely to unmap mapped pages. In short, the higher the
vm.swappinessvalue, the more the system will swap.
vm.swappinesstakes a value between
100to change the balance between swapping applications and freeing cache. At
100, the kernel will always prefer to find inactive pages and swap them out; in other cases, whether a swapout occurs depends on how much application memory is in use and how poorly the cache is doing at finding and releasing inactive items.
To lower this value you need to edit the
/etc/sysctl.conffile and add the following to the bottom
vm.swappiness = 10, and reboot.
Although this is a conglomeration of information already freely available on the web, I hope it helps you by requiring less reading and digesting. These settings are all working well for me, but perhaps your mileage may vary depending on your particular hardware or distro. If you feel I've done something dumb anywhere in here, or have better suggestions, please comment, I'd love to hear your opinions and best practices.