ramlog - daemon that places /var/log into ramdisk on startup and copies it back to harddisk on shutdown
/etc/init.d/ramlog start | stop | status | restart | reload | enable | disable | getlogsize | teststartstop | version
Ramlog act as a system daemon. On startup it creates ramdisk, it copies files from /var/log into ramdisk and mounts ramdisk as /var/log. All logs after that will be updated on ramdisk. Logs on harddrive are kept in folder /var/log.hdd which is updated when ramlog is restarted or stopped. On shutdown it saves log files back to harddisk so logs are consistent. Ramlog 2.x is using tmpfs by default, ramfs and kernel ramdisk are suppored as well. Program rsync is used for log synchronization.
Note: Logs not saved to harddrive are lost in case of power outage or kernel panic.
Install ramlog if you have enough of free memory and you want to keep your logs on ramdisk. It is good for notebook users, for systems with UPS or for systems running from flash - to save some write cycles.
How it works and what it does:
Ramlog starts among the first daemons (it depends on other daemons you have installed).
Directory /var/log.hdd is created and hardlinked to /var/log.
In case tmpfs (default) or ramfs is used, it is mounted over /var/log
If kernel ramdisk is used, ramdisk created in /dev/ram9 and it is mounted to /var/log, by default ramlog takes all ramdisk memory specified by kernel argument "ramdisk_size".
All other daemons are started and all logs are updated in ramdisk. Logrotate works on ramdisk as well.
In case ramlog is restarted (by default it is one time per day), directory /var/log.hdd is synchronized with /var/log using rsync. Frequency of the automatic log saves can be controller via cron, by default, the ramlog file is placed into /etc/cron.daily
On shutdown ramlog shuts among the last daemons.
During ramlog stop phase files from /var/log.hdd are synchronized with /var/log
Then /var/log is unmounted, /var/log.hdd is unmounted as well and empty directory /var/log.hdd is deleted.
This argument starts ramlog. However ramlog cannot be started anytime because /var/log can be already in use. That's why the best time to start ramlog is on system startup
Stops ramlog. The best time to stop ramlog is on system shutdown
Displays the status - if ramlog is started or stopped start
It is not really possible to "restart" ramlog. Ramlog called with this parameter saves all new or updated files from /var/log into /var/log.hdd
It does the same as restart
Configures ramlog as system daemon - it will start and stop with your system
Disables ramlog as system deamon. Use this option if you want ramlog to be disabled. In case you use any other external program to disable ramlog as system daemon, your unsaved logs will be lost(!)
ramlog returns the size of /var/log. It can be handy to know log size if you are about to change kernel parameter ramdisk_size
ramlog makes a test for open files in /var/log. If there are no open files, ramlog can be started or stopped
Displays actual version of ramlog
Ramlog configuration file is located in /etc/syconfig/ramlog on rpm based systems and in /etc/default/ramlog on deb based systems and you can set there below variables:
# 0 - tmpfs (can be swapped) - default
# 1 - ramfs (no max size in older kernels,
# cannot be swapped, not SELinux friendly)
# 2 - old kernel ramdisk
#Maximum size of memory to be used by tmpfs or ramfs.
# The value can be percentage of total RAM or size in megabytes - for example:
# Empty value means default tmpfs/ramfs size which is 50% of total RAM.
# For more options please check 'man mount', section 'Mount options for tmpfs'
# (btw - ramfs supports size limit in newer kernels
# as well despite man says there are no mount options)
# It has only effect if RAMDISKTYPE=0 or 1
#Kernel ramdisk size in kilobytes or MAX to use entire ramdisk.
#It has only effect if RAMDISKTYPE=2
# 0=off, 1=on Logs can be found in /var/log/ramdisk
# name of the ramlog log file (makes sense if LOGGING=1)
# 0=off, 1=on (if 1, teststartstop puts detials
# to the logs and it is called after start or stop fails)
Written by Jan Andrejkovic
Latest version can be downloaded from http://www.tremende.com/ramlog
Report bugs to <jandrejk on gmail point com>