Stop systemd‑journald from filling your Raspberry Pi’s 8 GB SD card with logs – how to cap its size

Why journald can eat your SD card

Running a Raspberry Pi on an 8 GB SD card is a rite of passage for home labs, IoT experiments, and low‑cost servers.
On Pi OS the default is to keep systemd‑journald persistent, so every log line ends up on that tiny flash drive.
In practice the Pi runs a handful of services—networking, SSH, Docker, custom scripts—that churn out logs faster than the card can keep up.
The result? The SD card fills up, you can’t install updates, and the OS itself starts to feel cramped.

The issue isn’t that you’re generating a lot of data; it’s that journald is configured to keep everything forever.
On a machine with limited storage you need to cap the journal size or move logs somewhere else.

Inspecting current usage

Before you start tweaking, take a look at what journald is actually eating:

# Show total journal size
journalctl --disk-usage

Typical output:

Archived and active journals take up 1.2 GB on disk

If that number is close to 8 GB, you’re in trouble.
You can also drill down into the individual files:

sudo du -sh /var/log/journal/*

And if you need a quick cleanup, vacuum the old entries:

# Remove entries older than 30 days
journalctl --vacuum-time=30d

That helps for now, but it won’t stop the journal from growing again.

Configuring size limits

The main lever to control journald’s disk usage is /etc/systemd/journald.conf.
The file is deliberately sparse; only the options you uncomment take effect.
On Pi OS the defaults look like this:

# /etc/systemd/journald.conf
[Journal]
#Storage=auto
#Compress=yes
#SystemMaxUse=
#SystemKeepFree=
#RuntimeMaxUse=
#RuntimeKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=
#MaxRetentionSec=
#MaxFileSec=

Persistent vs. volatile

  • Persistent (Storage=persistent) writes logs to /var/log/journal.
    That’s the default on Pi OS and the one that fills the SD card.

  • Volatile (Storage=volatile) keeps logs only in RAM (/run/log/journal).
    They’re gone on reboot, so they never eat disk space.
    If you don’t need logs after a reboot, switch to volatile:

    sudo sed -i 's/#Storage=auto/Storage=volatile/' /etc/systemd/journald.conf
    sudo systemctl restart systemd-journald
    

SystemMaxUse and SystemKeepFree

SystemMaxUse caps the total size of the persistent journal.
SystemKeepFree tells journald to leave a minimum amount of free space on the filesystem before it starts deleting old entries.

Example: keep the journal under 200 MB and leave at least 500 MB free:

[Journal]
SystemMaxUse=200M
SystemKeepFree=500M

On an 8 GB card you’ll probably want SystemKeepFree to be at least 1 GB so the OS still has breathing room.

RuntimeMaxUse

When you keep logs in RAM, RuntimeMaxUse limits how much memory journald can consume.
Useful on low‑memory devices to avoid swapping:

RuntimeMaxUse=50M

MaxRetentionSec and MaxFileSec

These options cap how long logs are kept, regardless of size.
MaxRetentionSec applies to all logs; MaxFileSec applies to individual files.

MaxRetentionSec=7d   # keep logs for 7 days
MaxFileSec=1d        # rotate files older than 1 day

Compress

Enabling compression shrinks disk usage at the cost of a bit of CPU.
On a Pi it usually pays off:

Compress=yes

Practical examples

Below are two common configurations you can drop into /etc/systemd/journald.conf.

Example 1: 200 MB limit, 1 GB free space

[Journal]
Storage=persistent
Compress=yes
SystemMaxUse=200M
SystemKeepFree=1G

After editing, reload the service:

sudo systemctl restart systemd-journald

Verify the new limits:

journalctl --disk-usage

You should see the journal size capped at ~200 MB.

Example 2: 7‑day retention, no size cap

If you prefer to keep logs for a week but don’t want to set a hard size limit:

[Journal]
Storage=persistent
Compress=yes
MaxRetentionSec=7d

This keeps the last 7 days of logs, deleting older ones automatically.
It’s a good middle ground if you want to keep a reasonable history without worrying about disk space.


Tuning journald is a one‑liner tweak that can save your Pi from a log‑driven death spiral.
Give it a try and watch the SD card stay healthy.


See also