Persistent Log Support¶
By default all the system logs generated by the Linux microPlatform are
stored in a tmpfs mount point (/var/volatile
), without persistent
support across reboots.
This is done as a way to minimize the amount of write operations to the disk (as is stored in memory), and to help reducing the amount of disk space utilized by the system.
While storing the system log in memory can reduce the load on the disk, it might not always be desired, specially during development, as being able to restore the log from previous recorded boots can provide useful information about the system.
Follow the instructions bellow to change the default LmP behavior and enable persistent logging support.
Disable OpenEmbedded VOLATILE_LOG_DIR¶
OpenEmbedded controls the /var/log
behavior via the VOLATILE_LOG_DIR
variable, which is enabled by default.
When enabled, OpenEmbedded links /var/log
to /var/volatile/log
(/var/volatile
is a tmpfs mount point), and when disabled it sets
/var/log
as a normal directory, making it persistent.
Add the following to conf/local.conf
or partner.inc
in order to disable
VOLATILE_LOG_DIR
:
VOLATILE_LOG_DIR = "no"
Add systemd-journald-persistent to your image¶
The recipe systemd-journald-persistent
provides a default configuration
file for systemd-journald that enables persistent logging support. The
default configuration sets a limit to 64M, which is safe for most
deployments.
Add systemd-journald-persistent
to lmp-factory-image.bb
(or any other
image used by your meta-subscriber-overrides layer), as described at
Adding Packages to the Image.
Optional: customize systemd-journald options¶
Note
Special attention is required when defining your own systemd-journald configuration file, as a high SystemMaxUse value might cause the logging to consume a substantial amount of disk space.
Create your own systemd-journald configuration file by overriding
the 10-persistent-journal.conf
file used by the
systemd-journald-persistent
recipe.
At your meta-susbscriber-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.