Here is a step-by-step procedure that can be automated with a script if someone is willing to do it. It can also be implemented it as a package (similar to Kevin Windrem packages).
I will paste file content in-line. If possible, will attach the files to an archive.
1) Downloading:
mkdir -p /data/my_files
cd /data/my_files
curl -L https://github.com/azlux/log2ram/archive/master.tar.gz | tar zxf -
cd log2ram-master
2) Install/copy and create the needed files to a systems dir in /data:
First creating log2ram system directory in /data so we can have all needed files to be easily copied to the needed places even after upgrade.
mkdir -p /data/log2ram_system
cp log2ram /data/log2ram_system/log2ram
chmod 755 /data/log2ram_system/log2ram
cp log2ram.conf /data/log2ram_system/log2ram.conf
chmod 644 /data/log2ram_system/log2ram.conf
cp log2ram.logrotate /data/log2ram_system/log2ram.logrotate
chmod 644 /data/log2ram_system/log2ram.logrotate
Creating the init script (SysV Init). This will provide proper start and sync on reboot and gracefull shutdown as well.
cat > /data/log2ram_system/log2ram-init.sh <<EOF
#!/bin/sh
#
# log2ram SysV Init script
# Developed by kivanov for VenusOS
#
### BEGIN INIT INFO
# Provides: log2ram
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Provides ramdrive for system logging
### END INIT INFO
# Init start
START=06
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
LOG2RAM_SCRIPT=/usr/local/bin/log2ram
CONFIG=/etc/log2ram.conf
# Check if all is fine with the needed files
[ -f $CONFIG ] || exit 1
[ -x $LOG2RAM_SCRIPT ] || exit 1
# Source function library.
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
case "$1" in
start)
echo -n "Starting log2ram: "
#touch /data/log2ram.started.$(date +"%Y-%m-%d_%T")
${LOG2RAM_SCRIPT} start
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
stop)
echo -n "Stopping log2ram: "
#touch /data/log2ram.stopped.$(date +"%Y-%m-%d_%T")
${LOG2RAM_SCRIPT} stop
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
sync)
echo -n "This operation is generally provided by cron."
while true; do
read -p "Continue (y/n)?" choice
case ${choice} in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
echo -n "Force log2ram write to disk on-the-fly from the cli: "
#touch /data/log2ram.synched.$(date +"%Y-%m-%d_%T")
${LOG2RAM_SCRIPT} write
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
status)
cat /proc/mounts | grep -w log2ram > /dev/null && { echo -ne "log2ram is running\n"; };
cat /proc/mounts | grep -w log2ram > /dev/null || { echo -ne "log2ram is NOT running\n"; };
exit $?
;;
restart)
$0 stop && sleep 1 && $0 start
;;
*)
echo "Usage: /etc/init.d/$(basename $0) {start|stop|sync|status|restart}"
exit 1
esac
exit 0
EOF
chmod 755 /data/log2ram_system/log2ram-init.sh
Creaging cron script which can be copied to cron daily/weekly/ etc folder or set manually in cron to be execuded for particular periods of time in order to sync the log ramdisk to the flash memory
cat > /data/log2ram_system/log2ram-cron.sh <<EOF
#!/bin/sh
#
# cron.daily/log2ram -- daily write/sync ramlog to disk
#
#
LOG2RAM_SCRIPT=/usr/local/bin/log2ram
CONFIG=/etc/log2ram.conf
# Check if all is fine with the needed files
[ -f $CONFIG ] || exit 1
[ -x $LOG2RAM_SCRIPT ] || exit 1
cat /proc/mounts | grep -w log2ram > /dev/null || { echo -ne "log2ram is NOT running\n"; exit 1; }
exec ${LOG2RAM_SCRIPT} write
EOF
chmod 755 /data/log2ram_system/log2ram-cron.sh
Finally fix ownership (if some of the copied filed are not owned by root)
chown -R root:root /data/log2ram_system
3) Configure log2ram setting:
Set the bellow parameters in /data/log2ram_system/log2ram.conf (editing the file using nano for example)
SIZE=100M
USE_RSYNC=true
MAIL=false
PATH_DISK="/data/log"
ZL2R=false
It Highly recommended to install rsync if it has not been installed yet:
opkg update
opkg install rsync
IMPORTANT: Install findmnt - needed to log2ram core tool:
opkg install util-linux-findmnt
4) Installing to system:
cd /data/log2ram_system
mkdir -p /usr/local/bin/
cp log2ram /usr/local/bin/log2ram
cp log2ram.conf /etc/log2ram.conf
cp log2ram-init.sh /etc/init.d/log2ram-init.sh
# we create daily cron for syncing
cp log2ram-cron.sh /etc/cron.daily/log2ram-cron.sh
[ -d /etc/logrotate.d ] && cp /data/log2ram_system/log2ram.logrotate /etc/logrotate.d/log2ram
Remove a previous log2ram version (if present for some reason):
rm -rf /var/log.hdd
rm -rf /data/log.hdd
# Make sure we start clean
rm -rf /var/hdd.log
rm -rf /data/hdd.log
5) Setting up init and check
update-rc.d log2ram-init.sh start 06 S . stop 80 0 6 .
If we want to disable:
update-rc.d -f log2ram-init.sh remove
Checking correct symlinks are installed:
ls -alh /etc/rcS.d/ # symlink should be present
ls -alh /etc/rc3.d/ # symlink should NOT be present
ls -alh /etc/rc6.d/ # symlink should be present
6) reboot
sync
reboot
After reboot - there should be log2ram tmpfs filesystem already mounted and log hdd:
cat /proc/mounts
df -h