Problems with log file on SSD

On my OpenWrt One I have moved the system.log to an SSD into the directory /work/logs. Every day at 23:59 a logrotate is started which removes a lot of unneccessary messages and copies the remaining ones to a daily /work/logs/system_DOW.log, where DOW is Mon, Tue etc.

After a reboot, the new messages are not written to /work/logs/system.log any more. A new logrotate after the reboot fixes the problem.

Maybe, the reason is the timing: Probably, logging is started before the SSD is mounted by /etc/rc.local.

Because an entry in the fstab did not work, I added the mount in the /etc/rc.local:

/etc/fstab

/dev/nvme0n1p1 /work btrfs subvol=@work,defauls 0 0

/etc/rc.local

# Mount the @work Subvolume permanently on the SSD
mount /dev/nvme0n1 /mnt/nvme
mount -o subvol=@work /dev/nvme0n1 /work
exit 0

Temporarily, I can do a restart of the logger directly after the mount in /etc/rc.local, but then I still lose messages before the mount in rc.local.

I would prefer a clean solution which mounts the SSD before the start of the logger if timing is reason for the loss of log messages.

Any ideas?

I have now added a “service log restart” after the mount in /etc/rc.local but I have still lost the messages before the mount.

The question is now: How can I mount the (at)work btrfs subvolume as /work before logger is started?

Copy current log to /tmp
Stop logger
Mount disk
Copy log back from /tmp
Start logger

Yes, you'll miss some messages this way too, unfortunately.

Maybe it might be better if you could resolve the fstab error? Mounts are typically part of init, rc.local runs much later.

This has been resolved in the development branch but has not been backported to stabled. In the meantime, a copy of that version of /etc/init.d/log is here https://www.wildtechgarden.ca/doc/presentations/zabbix-on-openwrt/configure-database-storage-and-logging-for-zabbix/#configure-system-logging-to-srvlog

It seems to work now:

I have installed block-mount and created /etc/config/fstab:

config global
option anon_swap '0'
option anon_mount '0'
option auto_swap '1'
option auto_mount '1'
option delay_root '5'
option check_fs '0'

config mount 'work'
option target '/work'
option fstype 'btrfs'
option options 'subvol=@work'
option enabled '1'
option uuid '93cd1a03-22db-4a7c-bbd0-282b45d7c194'

The subvolume is mounted correctly and the result of a “dmesg | grep BTRFS” gives the following result:

[ 17.612778] BTRFS: device fsid 93cd1a03-22db-4a7c-bbd0-282b45d7c194 devid 1 transid 125885 /dev/nvme0n1 scanned by block (960)
[ 17.624905] BTRFS info (device nvme0n1): first mount of filesystem 93cd1a03-22db-4a7c-bbd0-282b45d7c194
[ 17.634351] BTRFS info (device nvme0n1): using crc32c (crc32c-generic) checksum algorithm
[ 17.642562] BTRFS info (device nvme0n1): using free space tree
[ 17.652374] BTRFS info (device nvme0n1): enabling ssd optimizations
[ 17.658649] BTRFS info (device nvme0n1): auto enabling async discard

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.