Tuesday, 31 December 2013

How to optimize system for SSD storage?

SSD (Solid State Drive) is completely different than traditional HDD (Hard Disk Drive). The major difference is that SSD has latency time near zero, no matter from which sectors we are reading time after time. Because of that, there is no need to use complicated I/O scheduler, which gives you nothing more than increased CPU usage. Linux offers few I/O schedulers. For HDD, in most cases, cfq is the best, because it gives you most effective queue for this type of drive. But deadline or even noop would be better for SSD. If you are not sure which of them you should choose, use deadline. My tests told me, that deadline is usually slightly better.

To activate this I/O scheduler you should set in your kernel config:

CONFIG_DEFAULT_IOSCHED="deadline"

Swapiness

The next reasonable thing to do is to reduce swap usage, as much as possible. It is not a good idea to turn the swap off – several applications may not work properly. The solution is to modify swappiness.

You can check present setup by typing:

cat /proc/sys/vm/swapiness

and set the correct value permanently by appending:

echo 5 > /proc/sys/vm/swappiness

to the start up scripts, or by setting:

vm.swappiness = 5

in /etc/sysctl.conf.

This setting tells your system to use swap space only when your physical memory is totally used. It prevents Linux from copying data across your drive, which has no sense when fragmentation of data do not affect significally on the overall performance.

Mounting options


Let's modify mounting options a bit, which usually has to be made in /etc/fstab. Adding an option noatime may slightly increase your drive performance. For example:

/dev/sda1 / ext4 rw,noatime,errors=remount-ro 0 0

This setting prevents your system from updating inode access time (both for regular files and directories). This is useful, especially, when your disc has the better speed when reading than when writing. This can be used with both types of drives: SSD and HDD.

Conclusion


This is not, of course, everything, what can be done, but these few changes may help making your system a bit faster when using SSD storage.