Using Solid State Disks on Linux
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:
browser.cache.disk.parent_directory
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:
cat /sys/block/sda/queue/scheduler
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.
Also
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.
Please share what you’ve found out about these things. Thanks!
Tags: Linux, Samsung Group, SanDisk, Solid-state drive, SSD
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=7efb9419-5174-4426-a130-4af9f64d9dfd)
February 21st, 2009 at 10:48 am
[...] Filed under: General, Scaling — François Schiettecatte @ 11:18 am Great post on using solid state disks on Linux by Dan Weinreb. Solid-state disks (SSDs) are getting less expensive, faster, and larger. I just bought a [...]
February 21st, 2009 at 11:13 am
This convinced me that I could retire my concerns about number of writes to my SSD disk.
http://www.guardian.co.uk/technology/blog/2008/jan/16/sohowlongmighttheflashdr
February 21st, 2009 at 3:11 pm
Also of interest, Ted Tso’s article on aligning the FS with write blocks: http://tytso.livejournal.com/60368.html
February 21st, 2009 at 3:12 pm
(oops. sorry. read too quickly and missed you cited his article already.)
February 21st, 2009 at 3:18 pm
JFFS2 is designed for the raw MTD flash that’s been used in embedded devices for a long time, where the device does no wear-leveling or write-batching, it’s as dumb as it can be.
JFFS is not for generic block devices that happen to be flash underneath. It’s already slow enough on MTDs, using it pointlessly on a SSD would have pathological performance.
February 21st, 2009 at 9:05 pm
How many writes does noatime save compared to relatime?
February 21st, 2009 at 9:38 pm
You missed an r of the end of the command
cat /sys/block/sda/queue/scheduler
February 22nd, 2009 at 6:36 am
Andrew: Thank you! Fixed.
Nat: I don’t know. I saw at least two recommendations to make this setting, though.
A friend has been telling me that I shouldn’t even think of recommending ext2 over ext3. Of course, I totally agree that logging the metadata is a great idea. I was more trying to express the fact that there is so little advice out there about what Linux file system to use, and what advice you do find is not always terribly convincing. I was very surprised by this. I thought I’d do a quick Google search, and find out that “everybody knows” that the best Linux file system for SSD’s is such-and-such, and that would be it. I still don’t know why it didn’t turn out that way.
February 22nd, 2009 at 8:44 am
Does you really need a special file system to use a modern SSD that implement in hardware a ‘wear levelling’ algorithm ?
JFFS2 (or a more modern flash file system like UBIFS ) is somewhat necessary on flash devices without hardware to perform wear levelling.
It is clear that those new file systems carries in general better technology for flash devices that traditional file systems which were developed for spinning HDDs, But how do they deal with the fact that modern SSDs manufacturers include a hardware layer in their devices to let them perform well under a traditional OS ?
UBIFS :
http://www.inf.u-szeged.hu/sed/ubifs
http://lwn.net/Articles/276025/
February 22nd, 2009 at 5:24 pm
After fearther reading (particularly this thread http://lkml.org/lkml/2008/10/14/129 ) to try to respond to my precedent questions, here’s the big picture I’ve found about the current commercial wave of commonly available SSDs:
– There is no documented access to the raw NAND hardware, so you can not effectively use well known dedicated FS like UBIFS, JFFS2,
– Manufacturers implement a proprietary hardware layer on top of the raw flash and you are stuck with that. Actually, there is no standardized good controller technology and that is probably the origin of the confusion on the file system side.
– For reliability and performance you need to pay many bucks, and with that hardware, every common file system (ext3 etc) perform well.
Other interesting readings I’ve found on this topic :
http://valhenson.livejournal.com/25228.html
http://realworldtech.com/forums/index.cfm?action=detail&id=92756&threadid=92678&roomid=2
April 15th, 2009 at 10:57 am
If you want to read a reader’s feedback
, I rate this post for 4/5. Detailed info, but I just have to go to that damn google to find the missed bits. Thank you, anyway!