Problem: Systemd Journald Does Not Honor SystemMaxUse Settings for Journal Space

systemd
journal
problem

#1

Problem

Systemd Journald Does Not Honor SystemMaxUse Settings for Journal Space

You configure limits for disk usage of the systemd journal files but it appears they are not taken into account.

ucr set systemd/journald/SystemMaxUse=400M
systemctl restart systemd-journald

But:

root@ucs:~# journalctl --disk-usage
Archived and active journals take up 536.0M in the file system.

Solution

One goal of journald is to keep as many log entries as possible by regarding the configured limits. If one limit allows to store more entries it is preferred.

Journald calculates the effective values based upon several system variables. It takes into account the free disk space when starting up as well as the SystemKeepFree value (if set, otherwise the default of 15% of the disk size). If you want to enforce the SystemMaxUse, set SystemKeepFree to the current available disk space (plus some more…).
Use the ucr command to set:

ucr set systemd/journald/SystemMaxUse=400M
ucr set systemd/journald/SystemKeepFree=3500M
systemctl restart systemd-journald

Note You have to use fixed values here as systemd does not accept percentages!
Note2 SystemKeepFree is capped to 4G always!

Example

$ ucr get systemd/journald/SystemMaxUse
250M
$ df -h
filesystem    size    used  avail   used% mounted at
/dev/sda1      14G      4G    10G    29%  /
Dez 20 15:44:45 ucs systemd-journal[28852]: Permanent journal is using 288.0M (max allowed 250.0M, trying to leave 2.1G free of 10G available → current limit 288.0M).

Although the limit is configured for 250M journald consumes 288M and ignores the setting. This is because there is still plenty of disk space available- in this case more than the default values for SystemKeepFree (15% of 14G = 2.1G).

If you want to enforce the SystemMaxUse, set SystemKeepFree to a little bit more than is actually available. In this example set SystemKeepFree to 11G but it will be caped to 4G anyways.

See Also


Problem: journalctl Reports Errors: "Failed to open directory /dev/null/.config/systemd"