Ramdisk and Kubuntu

Last change 01/12/2009

Since I want my box to be power efficient, I decided to reduce hard-drive access. One easy way to do that is to use ramfs for quite some things.

Basic Idea

During the running time of a linux box there is tons of data generated which is - at least for the sake of my multimedia box - completely useless (especially in terms of long-term interest). Here are some things I encountered:

  • /tmp - required but can easily be ona ramdisk
  • various logfiles - tro to get rid of some by putting em to /dev/null - the rest goes to a ramfs as well
  • firefox cache - ramdisk it - its not really interesting after a reboot
  • /var/cache/apt/archives - this is where the .deb files are cached when upgrading - can be a ramdisk as well (better add a crontab to remove stuff since after an update it can become quite big)
This is basically it, I might want to add more, but most stuff will be on a ssd in future. I just want to keep the disks from spinning when they are not needed.

Background

The current (k)ubuntu creates a nice ramdisk on /dev/shm. I checked on my system (its been up for more than a month now) and figured some interesting data:

  •  I got around 20M of logfiles
  • I had 500M of deb files from upgrades
  • the rest of my var is only ~300M
  • per default /dev/shm is 1.6G
So basically everything is set. I got enough space for all my temp and log needs, just have to "reassign" the space

Configurations

Firefox: edit your prefs.js (found in ~/.mozilla/firefox/YOURPROFILE/prefs.js) and add the line:
user_pref("browser.cache.disk.parent_directory", "/dev/shm");

Apache/syslog/...: recreate directory structure and then mount it
rsync -d -a -r --include '*/' --exclude '*' /var/log /dev/shm/
   chmod -R 777 * /dev/shm/log
   mount -o bind /dev/shm/log/ /var/log/
This should happen very early in the boot process to get syslog and the others to write there...

deb cache: this is basically just a symlink to /dev/shm

Final Script


Site created with Corinis CCM