Adding Persistent Journal Storage

Add persistent journal storage if you want log entries to persist across reboots, for greater historical reference and for deeper auditing purposes.

By default, the systemd journal is stored in volatile storage under /run/log/journal. This storage is wiped at reboot. To create persistent journal storage, that's preserved after reboot, you can create the appropriate directory structure, set the correct permissions and edit the journald configuration.

  1. Create the persistent storage directory in /var/log/journal.
    sudo mkdir /var/log/journal
  2. Set the appropriate permissions and configure the directory for systemd-journald access.
    sudo systemd-tmpfiles --create --prefix /var/log/journal
  3. Optionally, create a systemd journald drop-in configuration file in /etc/systemd/journald.conf.d/ and set the Storage parameter to persistent.

    Creating a systemd journald drop-in configuration can help make it clearer that the configuration is set to use persistent storage. This step is optional because, by default, the storage is set to 'auto' and journald switches to persistent if the /var/log/journal directory exists.

    sudo mkdir /etc/systemd/journald.conf.d
    cat > /etc/systemd/journald.conf.d/00-storage.conf << EOF
    [Journal]
    Storage=persistent
    EOF
  4. Restart the systemd-journald service and flush the journal to force it to switch from volatile to persistent storage.
    sudo systemctl restart systemd-journald
    sudo journalctl --flush
  5. Validate that the journal has switched to persistent storage.

    You can check the /var/log/journal directory to ensure that it's populated with data.

    sudo ls /var/log/journal

    Also check the journal path that's configured in the journal:

    journalctl -F JOURNAL_PATH