Slightly less Random Ramblings

August 7, 2009

Solid State Ubuntu

Filed under: Uncategorized — Robert Wicks @ 4:01 am

I decided to install Ubuntu 9.04 to my 2GB CF card. I wanted to avoid wearing out the CF with writes, so I settled on this method. I installed the server to one partition, so /usr/local is in the root filesystem. You can create the script anywhere in the root filesystem, but i used /usr/local.

Create a /usr/local/bin/ file with the contents below:

rsync -a /var.perm/ /var/
mount -t tmpfs tmpfs -o mode=1777 /var
rsync -a /var.perm/ /var/

Make a soft link from it to /etc/rcS.d with:

ln –s /usr/local/bin/ /etc/rcS.d/

This will cause it to run right after the filesystems are mounted, before any services which write to /var are running.

Add a cron.hourly script to rsync from /var to /var.perm, and you are all set!

I modified this a bit after the inital post. I changed the script:

find /var/ -type f -exec rm -f {} \;
mount -t tmpfs tmpfs -o mode=1777 /var
rsync -a /var.perm/ /var/
mount -o relatime /dev/vgraid/lv_squid /var/spool/squid3

The find line is actually only needed once. I just deleted the files from the underlying (flash) filesystems, leaving the directory structure. No need to waste space. After that, I mount the /var manually, then copy the permanent files into it. Finally, since I run squid on this server, I mount the squid cache directories after /var. All the other local filesystems get loaded from the scripts in the /etc/rcS.d directory. I also have an hourly cron job which runs the following:

#!/bin/shrsync –delete-excluded –delete-after –exclude=*.pid \
–exclude=spool/squid3/??/??/* –exclude=cache/apt/archives/*.deb\
-av /var/ /var.perm/

This copies all the directory structure, and most files, from /var to the flash card. I skip the squid cache files, since they take up too much space.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: