This is the first blog post of a series talking about systemd. This serie will shows some useful commands for common scenarios.

This post is about managing the disk space used by journald.

systemd-journald is the systemd component who takes care of logging all system and unit’s messages. It typically stores its files in /var/log/journal/<id>/ , where your id is something like d705e54557314d359c077214ebf789d6.

Go and check how much space it is used there:

journalctl --disk-usage

Last time i checked on my Fedora notebook running with default configuration it was around 4GB: quite a lot of space for a notebook with a small SSD disk like mine.

So, I edited /etc/systemd/journald.conf and added the following line:

SystemMaxUse=500M

which basically says that log in general shouldn’t use more than 500 MBytes. Allowed units are K for KBytes, M for MBytes, G for GBytes.

If you prefer to limit your log by defining how many days (or weeks, or month) you wish to retain, you could use the variable MaxRetentionSec

MaxRetentionSec=15day

Other valid units are year, month, week, day, h or m.

Once you edited the configuration file, to apply your new settings issue a

systemctl restart systemd-journald

If you are fine with your default setup, and just need to free some space because you are in an emergency, you can use the commands:

journalctl --vacuum-time=2d

or

journalctl --vacuum-size=500M

which have immediate effects and won’t change your systemd-journald configuration.

For many more options, as always, take a look at the man page!

man journald.conf

visitors