Persistent Log Support
By default, system logs generated by the Linux® microPlatform (LmP) are stored in a tmpfs mount point (/var/volatile
),
without persistent support across reboots.
This is done to minimize both the number of write operations to the disk (stored in memory), and the amount of disk space used.
While storing the system log in memory can reduce the load on the disk, this may not always be desired. Especially during development, being able to restore the log from previous boots can provide useful information.
Follow the instructions below to enable persistent logging support.
Disable OpenEmbedded VOLATILE_LOG_DIR
OpenEmbedded controls the /var/log
behavior via the variable VOLATILE_LOG_DIR
, which is enabled by default.
This links /var/log
to /var/volatile/log
(/var/volatile
is a tmpfs mount point).
When disabled, /var/log
is set as a normal directory, making it persistent.
Add the following to meta-subscriber-overrides/conf/machine/include/lmp-factory-custom.inc
to disable VOLATILE_LOG_DIR
:
VOLATILE_LOG_DIR = "no"
Add systemd-journald-persistent to Your Image
The recipe systemd-journald-persistent
(in meta-updater
) provides a default configuration file for systemd-journald
.
This enables persistent logging support.
The default limit is set at 64M, which is safe for most deployments.
Add systemd-journald-persistent
to meta-subscriber-overrides/recipes-samples/images/lmp-factory-image.bb
(or any other image used by your meta-subscriber-overrides layer), as described in Adding Packages to the Image.
Optional: Customize systemd-journald Options
Note
Special attention is required when defining your own
systemd-journald
configuration file. A highSystemMaxUse
value may cause the logging to consume a substantial amount of disk space.
Create your own systemd-journald
configuration file by overriding 10-persistent-journal.conf
.
This is used by the systemd-journald-persistent
recipe.
Within your meta-subscriber-overrides
layer:
$ cat recipes-support/systemd-journald-persistent/systemd-journald-persistent.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
And:
$ cat recipes-support/systemd-journald-persistent/files/10-persistent-journal.conf
[Journal]
Storage=persistent
SystemMaxUse=32M
SystemMaxFiles=10
SyncIntervalSec=60
For the complete list of options supported by journald please check the journald.conf manual.