0

Setup

Using systemd 244 (244.5+) on kernel 4.19.62.

I want to set the total journal storage size to 100MB. Journald is set to volatile storage, so logs end up on /run/log/journal/... and RuntimeMaxUse should be used to set the storage quota as follows in /etc/systemd/journald.conf:

[Journal]
Storage=volatile
RuntimeMaxUse=100M
RuntimeMaxFileSize=2M

By tweaking these config values, the journal log size and quota do change and startup messages in journalctl also show change.

Between config value changes, I stop systemd-journald.service, delete all system* files under /run/log/journal/... and restart the service.

NOTE: when Storage=persistent and logs use /var/log/journal/, the equivalent SystemMaxUse is respected correctly. This appears to only be a bug in volatile/RuntimeMaxUse.

Observed bug

The RuntimeMaxUse (100M) is ignored. The journal quota is set to 64MB so long as RuntimeMaxFileSize is less than 32M.

If RuntimeMaxFileSize is set to more than 32M, the journal quota is set to double that value.

RuntimeMaxUse appears to be ignored in both cases.

Is this a bug in journald/systemd config handling? Why is RuntimeMaxUse ignored, and a value of 64M or double RuntimeMaxFileSize used as the journal quota instead?

I see there are a couple of places in the journald source where max_use can be set to double max_size:

Bug examples

With RuntimeMaxUse=100M and RuntimeMaxFileSize=2M a quota of 64M (instead of my requested 100M) is set, as seen in the journal startup messages:

systemd-journald[20312]: Runtime Journal (/run/log/journal/...) is 2.0M, max 64.0M, 62.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 2.0M.
-- Maximum allowed usage is set to 64.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 64.0M, of which 62.0M are still available.

Using RuntimeMaxUse=100M and RuntimeMaxFileSize=31M, 64M still used:

systemd-journald[20989]: Runtime Journal (/run/log/journal/...) is 8.0M, max 64.0M, 56.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 64.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 64.0M, of which 56.0M are still available.

Using RuntimeMaxUse=100M and RuntimeMaxFileSize=33M, the quota ends up 66M:

systemd-journald[21557]: Runtime Journal (/run/log/journal/...) is 8.0M, max 66.0M, 58.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 66.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 66.0M, of which 58.0M are still available.

Using RuntimeMaxUse=100M and RuntimeMaxFileSize=200M we break past the 100M limit, with 400M seemingly coming from double the RuntimeMaxFileSize of 200M:

systemd-journald[25271]: Runtime Journal (/run/log/journal/...) is 8.0M, max 400.0M, 392.0M free.
-- Runtime Journal (/run/log/journal/...) is currently using 8.0M.
-- Maximum allowed usage is set to 400.0M.
-- Leaving at least 1.5G free (of currently available 31.2G of disk space).
-- Enforced usage limit is thus 400.0M, of which 392.0M are still available.

1 Answer 1

1

The 64M was coming from an additional config file I was unaware of: /lib/systemd/journald.conf.d/00-systemd-conf.conf.

With that additional setting of RuntimeMaxUse=64M removed, I can now set the desired values in /etc/systemd/journald.conf.

Tip: use strace on journald startup to see what config files it really uses and which order they are read in. This is how the /lib config file was finally revealed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.