-   Slackware (
-   -   Reducing writes to SSD: mounting /var (and others) on RAM disks (tmpfs). (

sysfce2 05-29-2011 07:43 PM

Reducing writes to SSD: mounting /var (and others) on RAM disks (tmpfs).
I'm getting ready to do an installation of 13.37 which will be my first on a SSD. I would like to minimize the writes to it to (hopefully) increase its lifespan. What directories and/or sub-directories should I mount on RAM drives? I am not worried about RAM usage since I installed 16 GB in this new computer. Is there anything else I should be doing (differently)? Can anyone see any problems with this plan (particularly with the directories not restored)?

Here are my current thoughts:

Mount the SSD using the 'noatime' option in fstab. I am currently debating whether to use ext2 (to eliminate journalling writes) or ext4 although I am leaning towards ext4 since (I believe) that the journal will barely be used anyway if there are few writes to the drive.

Mount /tmp on a tmpfs: this one should be easy as I don't think I need to do anything more than creating a tmpfs in fstab for it.

Mount /var on a tmpfs: this one could be a little trickier. I believe I need to restore the directory structure and a good portion of the files in order for this to work.
The sub-directories I can just throw away (any I have to create the structure for at startup?):
cache db empty games lock man mail named run rwho spool state tmp
The ones to restore at startup but throw away at shutdown:
www X11 X11R6 yp
The ones to restore at startup and save at shutdown:
adm lib log

At which point in the startup/shutdown should I restore/save? I am planning on using rsync.
I'm thinking the save is probably fine in rc.local_shutdown (or is that too early?), but rc.local is probably too late for restore. The restore will probably be in rc.M and come just after:
# Save the contents of 'dmesg':
/bin/dmesg -s 65536 > /var/log/dmesg
(of course I'll skip the restore of dmesg in /var/log).
This is just before starting the system logger.

What about /proc? Is that just created in RAM or is any part of it written to disk while the system is running?

TobiSGD 05-29-2011 08:14 PM

I would definitely go for ext4, as far as I know ext2 doesn't have support for the TRIM function. To enble that you have to add the mount option discard for partitions on the SSD.
For a machine with that amount of RAM I doubt you will need a swap partition.

The only partitions I mounted to tmpfs on my laptop were /tmp and the ~/.cache directory. I don't find it practical to fiddle with the folders in /var.

marafa 05-29-2011 08:54 PM

nice project

i was thinking of getting my myself an ssd. which disk did you purchase and why?

anyways, my 2 cents worth on your issue: get a second disk, a sata3 for static data like /home or /var/www (if you do web development).

you should note that some directories are needed and cannot be thrown away. eg. on fedora /var/cache/yum is where the mirror speed file and sqlite db is kept. and then you have /var/lib and things like /var/lib/yum which has the yumdb of historical transaction (up to you to throw it away or not) or /var/lib/mysql where the actual databases are kept or /var/lib/libvirt where the qemu images are kept.

which brings me back to what i was thinking: my objective was to make boot up and shut down faster so /boot and /usr /sbin /bin and /lib would go on to the ssd but everything else which is used every so once in a while like /home and /etc/ and /var go on to the sata disk

but then again. this is all dependent on what your objective is

Daedra 05-29-2011 09:12 PM

check out this article

Theres a lot of useful info on SSD's and Linux.

P.S. The site seems to be down, hopefully it will be back up soon.

TobiSGD 05-29-2011 09:30 PM


Originally Posted by marafa (Post 4370571)
and /etc/ and /var go on to the sata disk

With /etc on a different partition you will run into serious problems. /etc can't be mounted on boot, since fstab, which contains the mount information, is on /etc.

jschiwal 05-29-2011 09:51 PM

The data in /var needs to be retained between reboots. You might want to look at aufs (advanced union file system) and have a tmpfs layer on top. This is similar to the configuration on the original eeepc which used cheap SSD drives.

For laptops, IMHO, not using swap and mounting partitions with the noatime option would be enough. Especially when you consider how a regular hard drive can get damaged over time from shock & motion.

sysfce2 06-26-2011 08:57 PM

Thanks for all the input guys: I've got the installation up and running and it appears to work great! The boot time is super fast, such that I now usually shut down the computer now at night (whereas before I didn't bother because it would take too long to get going again). The main change I ended up doing was adding the following to my fstab (along with the noatime and discard options):

        tmpfs        /tmp                tmpfs        size=8G,mode=0777        0        0
        tmpfs        /var/tmp        tmpfs        size=4G,mode=0777        0        0

The rest of the directories in /var I left alone as it looks like in Slackware very little is written there anyway (at least with the desktop services I have going) and I figured I would end up with too many headaches if I started messing with them.

Originally Posted by TobiSGD (Post 4370547)
I would definitely go for ext4, as far as I know ext2 doesn't have support for the TRIM function. To enble that you have to add the mount option discard for partitions on the SSD.
For a machine with that amount of RAM I doubt you will need a swap partition.

I did use EXT4 for the / partition with TRIM but EXT2 for the boot partition so that I could use GRUB for the boot loader (I usually just mount it manually when I update the kernel).
One thing I had trouble figuring out is how I was supposed to align the SSD partition, but I figured if I made /boot 256 MB with / taking the rest of sda I should be all right. Was that an erroneous assumption?

I did also make a large swap partition on the WD drive but that was mostly because it is so large anyway and I figured it could come in handy if I ever wanted to try to get hibernation working.


Originally Posted by marafa (Post 4370571)
nice project

i was thinking of getting my myself an ssd. which disk did you purchase and why?

anyways, my 2 cents worth on your issue: get a second disk, a sata3 for static data like /home or /var/www (if you do web development).

I bought an Intel X25-V SSD because it was on sale and I had heard that (at least the early) Intel SSDs had a good reputation.

I have /home mounted on one of the WD Green 2 TB drives. This is a desktop system so I bought the SSD purely for performance rather than shock & motion issues.

I wasn't really considering mounting /etc on another drive: my configuration does remain relatively static once set up and I figured that it is one of the directories that would benefit from SSD performance.

I did take a look at aufs too, but I figured it was probably overkill for my (immediate) situation. I'll definitely play with it though as I can see a few potential applications.

storkus 08-26-2011 02:00 AM

Thanks, sysfce2, for making this posting, and for everyone who replied. I just bought a Corsair Force 115 GB SSD from Fry's Electronics on sale yesterday (today is the last day) that I want to put in my 3yo or so laptop. This SSD apparently has some conflicts between certain BIOSes and its firmware--it sounds ACPI-related, but with all the complaints from winblows lusers, it can be hard to tell. I guess I'll know soon enough, but with a 15 day return window--14 days now--I need to hurry to find out!

ANYWAY, my laptop has far lower specs than the one above: 2GB PC-5300 that came with it, which has been more than enough for Slackware, but not for the icky vista that came with it; and the single HDD bay with a Toshiba SATA-1 5400 RPM 160GB slower-than-molasses drive in it (and the reason I want to upgrade).

WRT tmpfs, /tmp is obvious, but I'm thinking most of the files in /var/log should go there as well, once the machine is running stable. Also, while the article says you just need to turn off caching in Firefox, that obviously won't help with Flash and other plugins, and since a lot of guys are redirecting ".macromedia" to /tmp or even /dev/null anyway (and, frankly, so am I), it seems linking a lot of those "." directories to /tmp may be the way to go.

WRT swap, you need it for hibernation functionality; also some things, like Firefox's (and especially Flash's) memory leaks and running the GIMP for any reason will usually send some stuff in there, but not really thrash much. It seems to me having some swap shouldn't hurt the device overall.

As for TRIM, this I do know: TRIM is currently only supported in EXT4 and BTRFS, courtesy of the "discard" command. Since BTRFS is not ready for production yet, that leaves EXT4.

I was about to write that I'm not sure "noatime" was needed, but then I read this from Ted T'so:

So I guess I'll be using "noatime", after all. That entry also debunks using EXT2/3.

I kind of lost my way in all the links of how I got there, but here's some comments from some VERY respected people on the subject:

First, Ted T'so's has blogged at least 3 times on SSD's. His blog's main page is at

Second, Linus himself has weighed in on the subject; this link was from one of Ted's blogs:

I find this bit the most interesting:


Again, if your SSD vendor says "align to 64kB boundaries"
or anything like that, you really should tell them to go
away, and you should do what Val said - just get a real
disk instead. Let them peddle their crap to people who are
stupider than you, but don't buy their SSD.

So what you want to happen if you split an SSD into multiple
partitions is exactly nothing. It shouldn't matter
one whit. If it does, the SSD is not worth buying. If it is
so sensitive to access patterns that you can't reasonably
write your data where you want to, just say "No, thank you".
Wow. That's Linus for you. And if that's true, then--outside of TRIM/discard, we really shouldn't care how we set up our drives.

Anyway, I'm getting off work, so I'm "tying off" this message. I look forward to any comments when I look at this tomorrow.


All times are GMT -5. The time now is 04:14 PM.