Course contentsShow
← Security
Lesson 1479 of 3,05230. Operating System Security - MonitoringFree lesson

Persistent Journal Configuration

Configure persistent storage for systemd journal, manage disk usage limits, and control log rotation.

Persistent Journal Configuration

What You'll Learn

You'll learn how to configure systemd's journal to permanently store logs across reboots, manage disk space limits, and control automatic log rotation to maintain a secure and auditable logging environment.

Why Persistence Matters

By default on many Linux distributions, systemd's journal stores logs in volatile memory (/run/log/journal), meaning logs vanish after reboot. For security monitoring and incident response, you need a permanent record. Think of it like switching from a whiteboard that gets erased nightly to an actual logbook you can reference months later when investigating a breach.

Enabling Persistent Storage

Persistent journaling writes logs to /var/log/journal. Enable it by:

  1. Creating the directory: mkdir -p /var/log/journal
  2. Setting proper permissions: systemd-tmpfiles --create --prefix /var/log/journal
  3. Configuring in /etc/systemd/journald.conf:
[Journal]
Storage=persistent

Restart the service: systemctl restart systemd-journald

Managing Disk Usage

Unchecked logs can fill your disk—a security risk itself. Control growth with these settings in journald.conf:

SystemMaxUse=500M          # Maximum disk space for all logs
SystemKeepFree=1G          # Minimum free space to maintain
SystemMaxFileSize=100M     # Maximum individual journal file size
MaxRetentionSec=1month     # How long to keep old logs

The journal automatically rotates and deletes old files when limits are reached—like a circular buffer that overwrites the oldest data first.

Verifying Your Configuration

Check current usage: journalctl --disk-usage

Force rotation: journalctl --rotate

Manually clean old logs: journalctl --vacuum-time=2weeks or journalctl --vacuum-size=200M

Key Takeaway: Persistent journal configuration ensures critical security events survive reboots while automated limits prevent disk exhaustion—both essential for maintaining a reliable audit trail without causing operational disruptions.