Help me to understand armbian-ramlog where he log!

Recommended Posts

I realised, that my OrangePI Plus 2E doing the logrotate of /var/log.hdd and not /var/log dir

I'm using:


root@orangepiplus2e:~# lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

root@orangepiplus2e:~# uname -r

In my dir /etc/logrotate.d/ I realised that in every file standing: /var/log.hdd/.... as a path for logrotate even if I change to /var/log/... everytime when I restart my box.

Now if I understand correctly the ram part is named: /var/log/... what can I see from:

root@orangepiplus2e:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            939M     0  939M   0% /dev
tmpfs           202M  556K  201M   1% /run
/dev/mmcblk0p1   15G  4.6G  9.4G  33% /
tmpfs          1007M     0 1007M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs          1007M     0 1007M   0% /sys/fs/cgroup
tmpfs          1007M   44K 1006M   1% /tmp
mrtg2ram         10M  3.4M  6.7M  34% /var/www/mrtg
/dev/zram0      340M  7.1M  308M   3% /var/log
tmpfs           202M     0  202M   0% /run/user/0

Here I see that /dev/zram0 is mounted as /var/log. Size I changed in /etc/default/armbian-ramlog.

I inspected and found the file: /usr/lib/armbian/armbian-hardware-optimization is responsable for changing path from /var/log to /var/log/hdd


Now what I do not understand is if-else-fi part of function prepare_board() from this file.

CheckDevice=$(for i in /var/log /var / ; do findmnt -n -o SOURCE $i && break ; done)
# adjust logrotate configs
if [[ "${CheckDevice}" == "/dev/zram0" || "${CheckDevice}" == "armbian-ramlog" ]]; then
	for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/log\//\/log.hdd\//g" "${ConfigFile}"; done
	sed -i "s/\/log\//\/log.hdd\//g" /etc/logrotate.conf
	for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/log.hdd\//\/log\//g" "${ConfigFile}"; done
	sed -i "s/\/log.hdd\//\/log\//g" /etc/logrotate.conf

First line checking is it exist the path /dev/zram0

Secod line if yes then rename in every file from /etc/logrotate.d/ pattern /var/log to /var/log.hdd


If not do reverse...


Why is implemented this?

If all my logs going to /var/log and it's raising what is the logic, if the armbian-ramlog enabled, to rotate /var/log.hdd and not the /var/log ?

Who will then rotate /var/log if it will be full let it say after 12h or 96h?

This problem I had not on Armbian with kernel (Jessie), that after every restart the content of files in logrotate.d was renamed.

Because I'm not able to understand the logic bihind this I have opinion as it is reversed this if-else-fi part.


Would be someone so kind to explain me the logic?


Link to post
Share on other sites

Armbian is a community driven open source project. Do you like to contribute your code?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


1 1