eeePCs use solid state disks (SSD). I don't know if the lifespan of SSDs is a real issue for the average user, but I wanted to reduce writings anyway. This article pointed me (paragraph "Which file system should you use?") to the redirection of logs to /dev/null, but I didn't find any instruction on how to make it once and for all (I don't like running scripts every time an application is added or removed). This program (ramlog) pointed me to redirect logs to ram.
I tried installing ramlog on my eeePC 900, but without success.
I tried to mount /var/log on a ramdisk in fstab, but it didn't work because it results in an empty folder, while many programs need their own subfolder, otherwise they don't go (like kismet, for example).
So I tried my way:
- the eeePC has a /tmp folder mounted in ram on tmpsf;
- I only need to make a subfolder /tmp/log and to link /var/log there;
- copy current logs in /tmp/log at boot-up and save new logs from there to somewhere on the disk at shutdown.
My steps were:
- rename /var/log as /var/log-save;
- make a symbolic link: /var/log points to /var/log-save (in this manner, programs work as usual until the scripts are completed and running);
- in /usr/local/sbin create a simple script named "log-up" to be called at startup in order to:
- create directory /tmp/log;
- copy content of /var/log-save to /tmp/log;
- remove link /var/log (which is pointing to /var/log-save);
- make new link /var/log, pointing now to /tmp/log;
- in /usr/local/sbin create a simple script named "log-down", to be called at shutdown/reboot in order to:
- copy only newer or modified logs in /tmp/log back to /var/log-save;
- remove link /var/log (which is pointing to /tmp/log);
- make new link /var/log, pointing now to /var/log-save;
- in /usr/bin, edit "startsimple.sh" by adding at the beginning a call to "log-up" (bold lines):
- in /usr/bin, edit "startfull.sh" by adding at the beginning a call to "log-up" (bold lines):
- in /sbin, edit "fastshutdown.sh" by adding a call to "log-down" (bold lines):
- in /sbin, edit "fastreboot.sh" by adding a call to "log-down" (bold lines):
- reboot.
#!/bin/bash
mkdir /tmp/log
cp -rp /var/log-save/* /tmp/log
unlink /var/log
ln -s /tmp/log /var/log
#!/bin/bash
cp -rpu /tmp/log/* /var/log-save
unlink /var/log
ln -s /var/log-save /var/log
#!/bin/sh
# change logging dir
sudo /usr/local/sbin/log-up
sudo /usr/bin/sessreg -d -l :0.0 -u /var/run/utmp user
xhost + si:localuser:root # Allow local user root only to access the display
...
#!/bin/sh
# change logging dir
sudo /usr/local/sbin/log-up
touch /home/user/.kdesession #changed
killall xinit
#!/bin/sh
if [ "$1" = "--ask" ]
then
zenity --question && sudo $0
exit $?
fi
[ `id -u` = "0" ] || echo "Must be root."
# revert logging dir
/usr/local/sbin/log-down
/usr/bin/killall --wait usbstorageapplet
/bin/kill -USR2 1
#!/bin/sh
if [ "$1" = "--ask" ]
then
zenity --question && sudo $0
exit $?
fi
[ `id -u` = "0" ] || echo "Must be root."
#revert logging dir
/usr/local/sbin/log-down
/usr/bin/killall --wait usbstorageapplet
/bin/kill -USR1 1
If you don't care about keeping the the full log history, because you only need logs within a session, you may opt for similar scripts which only save the directory structure (needed by some program installation) but not the files (not needed from session to session).