pdaXrom: /var/log/ ins RAM verlegen

03 07 2005

Um das Logverzeichnis ins RAM zu verlegen, sind nur wenige kleine Aktionen nötig.

# cp /etc/rc.d/rc.rofilesys /home/root/rc.rofilesys.bak # cp /home/root/rc.rofilesys.bak /home/root/rc.rofilesys.new # vi /home/root/rc.rofilesys.new

Unter allen Vorkommen der Doppelzeile

mkdir /dev/shm/tmp mkdir /dev/shm/run

die Zeile "mkdir /dev/shm/log" einfügen (insgesamt zwei Mal). Dann

# mv /home/root/rc.rofilesys.new /etc/rc.d/rc.rofilesys # mv /var/log/ /var/log.bak # ln -s /dev/shm/log /var/log # reboot

und nach dem Neustart liegen die Logdateien im RAM. Die Größe des unter /dev/shm/ gemounteten tmpfs wird in der /etc/rc.d/rc.rofilesys übrigens auf 12 MB beschränkt, so daß der Hauptspeicher nicht vollaufen kann. Trotzdem sollte man darauf achtgeben, das Dateisystem nicht zu füllen. Außerdem ist zu bedenken, daß nun die Startskripte aller Dienste angepaßt werden müssen, die in Verzeichnisse unterhalb von /var/log/ schreiben wollen.
Für lighttpd zum Beispiel muß die /etc/rc.d/init.d/lighttpd vor dem Aufruf des Daemons nun etwa wie folgt geändert werden:

# Create the log dir, if necessary if [ ! -d /var/log/lighttpd/ ]; then     mkdir /var/log/lighttpd/     chown nobody:nobody /var/log/lighttpd/ fi

[See English translation below]

pdaXrom: relocating /var/log/ to RAM

Relocating the log directory to RAM needs just a few small actions.

# cp /etc/rc.d/rc.rofilesys /home/root/rc.rofilesys.bak # cp /home/root/rc.rofilesys.bak /home/root/rc.rofilesys.new # vi /home/root/rc.rofilesys.new

Below all occurrences of the double line

mkdir /dev/shm/tmp mkdir /dev/shm/run

add the line "mkdir /dev/shm/log" (two times overall). Then

# mv /home/root/rc.rofilesys.new /etc/rc.d/rc.rofilesys # mv /var/log/ /var/log.bak # ln -s /dev/shm/log /var/log # reboot

and the log files are in RAM after the reboot. The size of the tmpfs which is mounted on /dev/shm/ is restricted to 12 MB in /etc/rc.d/rc.rofilesys by the way, so the main memory won't be flooded. You should look out to not fill the file system nonetheless. Apart from that you should keep in mind that all init scripts of services that write to subdirectories below /var/log/ have to be modified now.
In the case of lighttpd for instance the /etc/rc.d/init.d/lighttpd has to be altered as follows before calling the Daemon:

# Create the log dir, if necessary if [ ! -d /var/log/lighttpd/ ]; then     mkdir /var/log/lighttpd/     chown nobody:nobody /var/log/lighttpd/ fi


Trackbacks


05 07 2005
pdaXrom: /var/log/ ins RAM verlegen
Um das Logverzeichnis ins RAM zu verlegen, sind nur wenige kleine Aktionen nötig. # cp /etc/rc.d/rc.rofilesys /home/root/rc.rofilesys.bak # cp /home/root/rc.rofilesys.bak /home/root/rc.rofilesys.new # vi /home/root/rc.rofilesys.new Unter allen Vor
Weblog: Sil53r Surf3r
Aufgenommen: Jul 05, 00:40

Kommentare

Ansicht der Kommentare: (Linear | Verschachtelt)
Noch keine Kommentare

Kommentar schreiben


Die angegebene E-Mail-Adresse wird nicht dargestellt, sondern nur für eventuelle Benachrichtigungen verwendet.

Um maschinelle und automatische Übertragung von Spamkommentaren zu verhindern, bitte die Zeichenfolge im dargestellten Bild in der Eingabemaske eintragen. Nur wenn die Zeichenfolge richtig eingegeben wurde, kann der Kommentar angenommen werden. Bitte beachten Sie, dass Ihr Browser Cookies unterstützen muss um dieses Verfahren anzuwenden.
CAPTCHA

Umschließende Sterne heben ein Wort hervor (*wort*), per _wort_ kann ein Wort unterstrichen werden.
Gravatar/Pavatar/Favatar/Pavatar Autoren Bilder werden unterstützt.