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?
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.
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
check out this article http://cptl.org/wp/index.php/2010/03...ives-in-linux/
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.
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.
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):
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.
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.
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 http://www.linuxfoundation.org/blog/9
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:
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 08:25 PM.|