Solid-state disks (SSDs) are getting less expensive, faster, and larger. I just bought a lightweight laptop with 128GB of SSD instead of a disk. Just to see what I’d find out, I poked around on the web looking for information how to use SSD’s under Linux. Keep in mind that I am not an expert on SSD’s, nor on Linux! Bearing that in mind, here’s what I found:
Tuning Linux for SSDs
Here a quick summary of Tom Bryer’s “Four Tweaks for Using Linux with Solid State Drives” (Sept 2008)
If you’re using Linux with SSD’s, it is recommended to use the noatime option to turn off writing the “last accessed time” attribute to files. This avoids writes, increasing the lifetime of the SSD. (As root, edit /etc/fstab and change “relatime” to “noatime” on SSD partitions. This might only apply to ext3.)
You can create a tmpfs partition (in RAM) and make Firefox use it for its cache, to reduce disk writes. Edit the file /etc/fstab and add:
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
Then, in Firefox, open about:config, right click in an open area, create a new string value called:
and set it to /tmp.
If you write a large file to the disk, Linux will stop any other application’s attempts to write, potentially for a long time. To greatly reduce the pause, change the I/O scheduler for SSD’s. Do:
to get the current scheduler for a disk (sda, in this case) and to see the alternative options. You’ll probably have four options, the one in brackets is currently being used by the disk specified in the previous command:
noop anticipatory deadline [cfq]
Now do (as root):
echo deadline > /sys/block/sda/queue/scheduler
File Systems for SSDs
What’s a good Linux file system to use for SSD’s? A lot of people have asked this on the web and gotten very few straight answers. There is jffs2 but everybody seems to think it’s lousy. Some people think that ext2 is considered better than ext3, which is a journaling file system that does more writes. However, journaling keeps the file systems’ metadata consistent after a crash, so it’s quite valuable. Surely there’s a lot more to say that this, but I wasn’t able to find it.
SanDisk has announced ExtremeFFS. It looks like this is not a Linux file system, but rather the hardware acts like a disk. If so, one could take advantage of this technology from non-Linux machines.
Samsung says that ExtremeFFS uses a non-blocking architecture in which all of the NAND channels of the SSD can behave independently. It can read and write at the same time. They also claim that it can speed up random writes by 100x! How they do it is explained in this article by Chris Mellor. They avoid the need for erases in a lot of cases. Also there is a garbage collector!
I found a comment saying that “this sounds like what Fusion-io is doing on the ioDrive.” Fusion-io makes very high-speed SSD’s.
Although one person points out that your SSD may outlive your laptop, or you can replace it with a larger, cheaper, faster one that will be around at that time (assuming that you can get your data off before it’s too late). But avoiding journaling is also good for speed, not just longevity.
It’s good to align your file system on an erase-block boundary. Especially if you’re using RAID, so that a whole stripe can be copied efficiently. You want your partition aligned on a 128K boundary. Theodore Tso’s blog item provides vast technical detail.