Using tmpfs with mandriva 2009

This article describes what I did to use tmpfs (= a ramdisk) for /tmp, /var/tmp and /var/log.

The advantages of doing this are:

  • Limit write operation to disk
  • Save SSD life
  • Save battery life

The drawbacks are:

  • Logs are lost after reboot
  • System can not be up 24/24 7/7 as logs will fill the memory up.

Thus this modification is very good for laptop and especially netbooks.

Add this to /etc/fstab:

none /tmp tmpfs noatime 0 0
none /var/tmp tmpfs noatime 0 0
none /var/log tmpfs noatime 0 0

Syslog requires a certain number of subdirectories to exist in /var/log. You need to hack the /etc/rc.sysinit file.
Edit /etc/rc.sysinit:

Search for “#Mounting Encrypted filesystem” and add this before:

# ADDED LORDIKC
echo "Creating /var/log/* directories"
for d in /var/log/mail /var/log/cron /var/log/kernel /var/log/daemons /var/log/subsys /var/log/security /var/log/ntpstat
s; do
test -d $d || mkdir $d -m 755
done
# /ADDED LORDIKC

You may want to boot this to clean /tmp, /var/tmp and /var/log.

This entry was posted in EEE PC, Informatique, mandriva and tagged , , . Bookmark the permalink.

5 Responses to Using tmpfs with mandriva 2009

  1. Joris says:

    For /var/log, an alternative is :
    mv /etc/syslog.conf /etc/syslog.conf.bak
    vi /etc/syslog.conf
    *.* /dev/tty1
    :x
    service syslog restart

    has it, no more hard disk logging

    Joris

  2. Sergio says:

    Hi Lordikc, I tested that on Mandriva 2009.1 and worked partially. I mean: directories are created and /var/log is mounted but for example /var/log/kernel/*.log files are empty.

    What’s wrong with it?

    Thanks in advance

  3. lordikc says:

    Hi Sergio,

    I think you missed the last part of the post.

    Regards

  4. Sergio says:

    Hi Lordick, are you referring to “You may want to boot this to clean /tmp, /var/tmp and /var/log.” ?

    Because I edited fstab and rc.sysinit files. Except that I didn’t move /var/tmp because caused troubles at starting a KDE session…

    Regards

  5. lordikc says:

    Sorry I missed the point that you’re running 2009.1.
    I made this for 2009 and still use it on my EEE-701 running 2009.
    I no longer use it on 2009.1 since I encountered same kind difficulties.
    I submit this as a bug but I doubt it will be solved one day since it’s mostly a hack although I think syslog and other daemons should create necessary folders themself. I also think that this kind of hack will be very interesting within SSDs.

    Regards