When a Linux server runs out of disk space, logs are one of the first things to check. Our logrotate guide covers text log files in /var/log. This guide covers the other big log store on modern servers: the systemd journal, written by systemd-journald and read with journalctl. The journal is not managed by logrotate. It has its own size limits, which you set in journald.conf.
You will learn how to:
- check how much space the journal uses and where it is stored,
- understand the default limits so you know whether you need to change them,
- set your own size and age limits in a drop-in file,
- free space right now with
journalctl --vacuum-*without breaking anything, - find the service that writes the most log lines, and
- confirm that the new limits are in effect.
The commands work on current Ubuntu and Debian releases and on most other systemd-based distributions. Run them as a user with sudo rights.
1. Check how much space the journal uses
journalctl --disk-usage
Example output:
Archived and active journals take up 3.8G in the file system.
This total covers both the active journal files (the ones being written now) and the archived files (older files that are closed and only read).
Next, check where the journal is stored. journald can keep logs in one of two places:
/var/log/journal/is persistent storage, kept on disk across reboots./run/log/journal/is volatile storage in RAM (tmpfs), lost at reboot.
ls -ld /var/log/journal /run/log/journal 2>/dev/null
sudo du -sh /var/log/journal /run/log/journal 2>/dev/null
Which one is used depends on the Storage= setting. The default is Storage=auto, which means: store logs persistently if the /var/log/journal directory exists, otherwise keep them only in /run/log/journal. On most current Ubuntu and Debian server installs that directory exists, so the journal is written to disk. That is useful for troubleshooting, but it is also why it can grow large.
2. Know the default limits
journald already limits its own size, even if you never change anything. Per the official journald.conf(5) manual, the defaults for persistent storage are:
| Setting | What it controls | Default |
|---|---|---|
SystemMaxUse= | Maximum disk space all journal files in /var/log/journal may use | 10% of the file system size, capped at 4G |
SystemKeepFree= | Disk space journald always leaves free for other programs | 15% of the file system size, capped at 4G |
SystemMaxFileSize= | Size at which a single journal file is closed and a new one started | One eighth of SystemMaxUse= |
SystemMaxFiles= | Maximum number of archived journal files to keep | 100 |
MaxRetentionSec= | Delete entries older than this age | 0 (no age limit) |
MaxFileSec= | Maximum time span stored in one journal file before it is rotated | 1month |
journald applies both SystemMaxUse= and SystemKeepFree= and uses whichever is smaller. The Runtime* settings (RuntimeMaxUse=, RuntimeKeepFree= and so on) work the same way for the volatile journal in /run/log/journal.
So on a 40 GB root disk, the journal can use up to about 4 GB by default, as long as enough free space remains on the disk. On a small VPS that may be more than you want, especially next to databases, backups and container images. On a large disk the 4G cap still applies, which is often fine.
3. Set your own limits in a drop-in file
Do not edit /etc/systemd/journald.conf directly. Put your changes in a drop-in file instead. Drop-ins are kept when packages are upgraded and are easy to review or remove.
sudo mkdir -p /etc/systemd/journald.conf.d
sudo nano /etc/systemd/journald.conf.d/50-size-limits.conf
Example content for a small server:
[Journal]
# Keep the journal on disk across reboots
Storage=persistent
# Total disk space for all journal files
SystemMaxUse=500M
# Always leave at least this much free on the file system
SystemKeepFree=1G
# Size of each journal file before a new one is started
SystemMaxFileSize=50M
# Delete entries older than one month
MaxRetentionSec=1month
Notes on the values:
- Sizes accept the suffixes
K,M,GandT. They are base 1024, so500Mmeans 500 MiB. - Time values accept units such as
s,min,h,day,week,monthandyear. Storage=persistenttells journald to create/var/log/journalif it is missing. Leave this line out if you are happy with the current behaviour.- Pick a
MaxRetentionSec=value that matches how far back you actually investigate problems, and any log retention rules your organisation must follow. If you need long-term logs, ship them to a central log server instead of keeping months on every machine.
Check the merged configuration (the main file plus all drop-ins, in the order systemd reads them):
systemd-analyze cat-config systemd/journald.conf
Then restart journald so it reads the new settings:
sudo systemctl restart systemd-journald
On current systemd versions, restarting journald does not stop your services, and logging continues straight away. journald applies the new limits when it opens and rotates its files. If journalctl --disk-usage still shows more than your new limit, run the rotate and vacuum steps in the next section once.
4. Free space right now with vacuuming
If the disk is already full and you need space immediately, use the vacuum options of journalctl. They delete archived journal files, oldest first, until the condition is met:
# Keep at most 500 MB of archived journal files
sudo journalctl --vacuum-size=500M
# Delete archived files that only contain entries older than two weeks
sudo journalctl --vacuum-time=2weeks
# Keep only the 5 most recent archived journal files
sudo journalctl --vacuum-files=5
Vacuuming only removes archived files. The active file that journald is writing to is not touched. If most of the data is in the active file, the vacuum frees less than you expect. In that case, rotate first so the active file is closed and archived, then vacuum:
sudo journalctl --rotate
sudo journalctl --vacuum-size=500M
journalctl --disk-usage
Important points:
- Vacuuming is permanent. Deleted log entries cannot be recovered. If you are investigating an incident, export the relevant logs first, for example
journalctl --since "2026-11-30" --until "2026-12-01" > incident.log. - Do not delete files in
/var/log/journalwithrmwhile journald is running. Use the vacuum options, which are designed for this. - A vacuum is a one-off cleanup. Without the limits from step 3, the journal grows back to its previous size.
5. Find the service that writes the most logs
A journal that grows very fast usually means one service is too noisy: a debug log level left on, a crash loop, or a client retrying a failed connection many times per second. Limits hide the symptom, so it is worth finding the cause.
Count today's log lines per program name. This is a quick estimate based on the default short output format, where the fifth column is the program name:
journalctl --since today -o short --no-pager \
| awk '{print $5}' | sed 's/\[.*//; s/:$//' \
| sort | uniq -c | sort -rn | head -15
Then look at the top entries:
journalctl -u nginx.service --since "1 hour ago"
systemctl status myapp.service
Fix the cause where you can: lower the application's log level, fix the crash loop or the failing connection. If a service is still too chatty, you can limit it per unit with a systemd drop-in (sudo systemctl edit myapp.service):
[Service]
# Drop messages less important than "info" (debug lines are discarded)
LogLevelMax=info
# Allow at most 1000 messages per 30 seconds from this service
LogRateLimitIntervalSec=30s
LogRateLimitBurst=1000
Then restart the service: sudo systemctl restart myapp.service. journald also has global rate limiting by default (RateLimitIntervalSec=30s and RateLimitBurst=10000 in journald.conf). When a service hits it, journald logs a message saying that messages were suppressed. If you see those messages, that service is the one to look at.
6. Verify the result
After restarting journald, it logs a line that states the current size, the limit and the free space it keeps:
journalctl -u systemd-journald -b --no-pager | tail -n 5
Look for a line similar to this:
System Journal (/var/log/journal/...) is 312.0M, max 500.0M, 187.9M free.
The max value should match your SystemMaxUse= (or be lower, if SystemKeepFree= is the stricter limit). Also check the totals:
journalctl --disk-usage
df -h /var
To check that the journal files are not damaged, for example after a disk-full event, run:
sudo journalctl --verify
Common problems
- The vacuum freed almost nothing. Most data is in the active file. Run
sudo journalctl --rotatefirst, then vacuum again. - The new limits have no effect. Check that the drop-in file ends in
.conf, is in/etc/systemd/journald.conf.d/and starts with a[Journal]line. Confirm withsystemd-analyze cat-config systemd/journald.conf, then restartsystemd-journald. - Logs disappear after every reboot. The journal is volatile. Create persistent storage with
Storage=persistentin a drop-in and restart journald. /var/log/syslogis also large. On systems that run rsyslog, many messages are also written to text files in/var/log. Those files are rotated by logrotate, not by journald. See our logrotate guide.- The disk is still full. The journal may not be the cause. Check other large directories with
sudo du -xh --max-depth=1 / | sort -h | tail.
Quick checklist
- Check usage with
journalctl --disk-usage. - Set
SystemMaxUse=,SystemKeepFree=and, if needed,MaxRetentionSec=in/etc/systemd/journald.conf.d/50-size-limits.conf. - Restart with
sudo systemctl restart systemd-journald. - For immediate space, run
journalctl --rotateand thenjournalctl --vacuum-size=or--vacuum-time=. - Find and fix noisy services instead of only raising limits.
- Confirm the new limit in the journald startup message.
Sources
- systemd manual: journald.conf(5)
- systemd manual: journalctl(1)
- systemd manual: systemd-journald.service(8)
- systemd manual: systemd.exec(5) (LogLevelMax, LogRateLimitIntervalSec, LogRateLimitBurst)
