How-to 2 min read
Keep the systemd journal across reboots and cap its size
Make journald keep logs across reboots, set a size ceiling, verify it worked, and undo it. Applies to systemd-based Linux distributions.
The Solnyxus team
Updated Reviewed
On this page
By default some systemd distributions keep the journal only in memory, so the logs you most need after a crash disappear with the reboot. This guide makes the journal persistent and puts a limit on the disk it may use.
Prerequisites
- A Linux system running systemd with
systemd-journald. - Root access or
sudo. - Enough free disk space for the size limit you choose (check with
df -h /var).
Steps
Verify it worked
Trim the journal manually (optional)
To free space immediately, remove old archived entries by size or age:
Bash
sudo journalctl --vacuum-size=500M
sudo journalctl --vacuum-time=30d
Undo
Troubleshooting
- Only one boot is listed after a reboot: confirm
/var/log/journalexists and that the restart in step 5 succeeded (systemctl status systemd-journald). - A setting seems ignored: drop-in files are read in alphabetical order and later files win; check for other files with
systemd-analyze cat-config systemd/journald.conf. - Distribution defaults differ: some distributions already enable persistent storage. If step 1 already lists several boots, no change is needed.
For the full list of options, see man journald.conf and man journalctl.