Save Disk Space on Linux: How to Configure journald
Learn how to configure journald in Linux to control log retention, limit systemd disk usage, and safely reclaim gigabytes of storage.
Anyone managing Linux servers or workstations has faced that frustrating moment when a root partition full alert pops up out of nowhere—even though you haven't installed a single new package. On modern distributions like Debian 13.7 and Ubuntu 26.04.1, one of the primary silent culprits behind this bloated storage consumption is systemd's built-in log collector. Knowing how to configure journald is an essential skill for any developer or sysadmin looking to keep their system stable, predictable, and free from sudden disk space exhaustion.
systemd-journald is a system service responsible for capturing stdout, stderr, syslog, and kernel messages from all processes managed by systemd. It centralizes diagnostic data into indexed binary files, which makes querying logs exceptionally fast when using the journalctl utility. However, the default out-of-the-box configuration on many distributions allows journald to consume up to 10% of the total filesystem size or up to 4 GB of persistent storage. On a busy web server or a local dev machine running containerized microservices, that default ceiling can be reached within weeks, eating up dozens of gigabytes that database engines and user applications could otherwise put to good use.
Why Does /var/log/journal Keep Growing Unchecked?
The runaway growth inside /var/log/journal comes down to how systemd-journald handles log file lifecycles. By default, the service writes structured binary log files under a directory named after the machine's unique ID (Machine ID). Unlike traditional plain-text log files managed by older utilities like logrotate, journald files maintain internal indexes to ensure fast lookups by metadata like UID, PID, and systemd unit.
When a service streams logs continuously, the active journal file reaches a preset size, gets closed, and rotates to archived status. If no explicit quota rules are configured, journald keeps creating new journal files until it hits the global system limit calculated from partition size. On production servers with 500 GB or 1 TB NVMe SSDs, a 10% default cap can easily hoard 50 GB to 100 GB of historical log data you rarely actually need.
Furthermore, crash-looping services, Python applications spewing verbose stack traces every second, or debug logging left enabled in staging environments accelerate this accumulation exponentially. Understanding the difference between volatile logs (stored in RAM under /run/log/journal) and persistent logs (saved on disk under /var/log/journal) is the first step toward taking control of log retention.
How to Diagnose Disk Space Used by journalctl Logs
Before touching any configuration file, you need to measure the exact disk footprint journald logs are occupying on your SSD or NVMe drive. The systemd ecosystem provides built-in audit tools for this exact purpose.
The primary command to check journal storage footprint is journalctl --disk-usage. When executed in your terminal, the utility scans the log storage directory and outputs the total space consumed by active and archived journal files:
journalctl --disk-usage
The command output will look similar to:
Archived and active journals take up 4.2G in the file system.
For a detailed breakdown of individual files or to check for corrupted journal files, list the storage directory directly using standard Linux shell tools:
sudo du -sh /var/log/journal/*
sudo ls -lh /var/log/journal/$(cat /etc/machine-id)
Another useful diagnostic step is inspecting log instance headers to see the exact time range your log files cover. Running journalctl --header outputs start and end timestamps for log entries in active files, helping you spot whether you are holding onto unnecessary logs from six months ago.
Step-by-Step: How to Configure journald to Limit Disk Usage
The recommended way to customize systemd-journald settings is not by editing the primary /etc/systemd/journald.conf file directly, as OS upgrades can overwrite your changes. Instead, modern Linux best practice uses drop-in configuration files inside /etc/systemd/journald.conf.d/.
Default journald.conf file:

Follow the steps below to apply strict, safe caps on storage consumption:
1. Create the Custom Configuration Directory
Open your terminal with root privileges or use sudo to create the drop-in directory if it does not already exist:
sudo mkdir -p /etc/systemd/journald.conf.d
2. Create the Storage Limit Configuration File
Create a file named 00-storage-limit.conf using your preferred text editor (such as nano or vim):
sudo nano /etc/systemd/journald.conf.d/00-storage-limit.conf
3. Add Quota Control Parameters
Add the following configuration block to the file. These directives instruct systemd to keep journal logs on disk while enforcing a strict global size cap, required free space buffers, and per-file size limits:
[Journal]
Storage=persistent
SystemMaxUse=1G
SystemKeepFree=2G
SystemMaxFileSize=100M
SystemMaxFiles=10
Here is what each parameter does:
Storage=persistent: Ensures logs are written to disk at/var/log/journaland persist across system reboots.SystemMaxUse=1G: Sets the absolute maximum disk space that all combined log files can occupy. In this example, logs are capped at 1 Gigabyte.SystemKeepFree=2G: Guarantees journald will stop writing if available partition space drops below 2 Gigabytes.SystemMaxFileSize=100M: Restricts individual binary log files to 100 Megabytes. Once reached, the file rotates.SystemMaxFiles=10: Limits the total count of retained journal files (active and archived) to 10 files max.
4. Validate and Apply the Configuration
After saving and closing the file, verify configuration syntax and restart the systemd-journald service to apply the new limits immediately:
sudo systemd-analyze cat journald.conf
sudo systemctl restart systemd-journald
Re-check disk consumption using journalctl --disk-usage. systemd automatically triggers log cleanup to bring existing logs down to your newly defined thresholds.
How to Set Time-Based Retention Limits in journald.conf
In addition to setting byte and megabyte quotas, setting time-based log retention limits is crucial. In environments subject to compliance standards or on development servers, storing logs older than 14 or 30 days wastes disk resources without adding value.
The table below summarizes key time and rate-limiting directives available in journald.conf to optimize your retention policy:
| Directive | Description | Recommended Value | Use Case |
|---|---|---|---|
MaxRetentionSec |
Absolute maximum time to retain any log entry. | 14d or 1month |
General web servers and API endpoints |
MaxFileSec |
Maximum lifespan of an active log file before rotation. | 1day |
Moderate-traffic environments |
RateLimitIntervalSec |
Time window used to monitor log rate bursts. | 30s |
Protection against crash loops |
RateLimitBurst |
Maximum messages allowed within the time window. | 10000 |
Log-based denial of service prevention |
To include a 14-day temporal retention limit and protect against noisy services, update your /etc/systemd/journald.conf.d/00-storage-limit.conf file with time parameters:
[Journal]
Storage=persistent
SystemMaxUse=1G
SystemKeepFree=2G
SystemMaxFileSize=100M
MaxRetentionSec=14d
RateLimitIntervalSec=30s
RateLimitBurst=10000
The RateLimitBurst setting prevents a broken Python application in an infinite loop from thrashing disk I/O by attempting to write hundreds of thousands of log lines per second.
How to Manually Flush journald Logs Without Rebooting
If your server partition is already at 100% capacity and you need to free up disk space immediately before setting up permanent rules, journalctl provides quick cleanup options known as vacuuming flags.
You can run emergency cleanup using size, time, or file count criteria without restarting the OS or interrupting running applications.
To instantly trim total log storage down to a fixed target size, use the --vacuum-size flag:
sudo journalctl --vacuum-size=500M
To delete logs older than one week, use --vacuum-time:
sudo journalctl --vacuum-time=7d
To restrict log storage to a specific number of archived files, use --vacuum-files:
sudo journalctl --vacuum-files=5
Before running vacuum commands, an important best practice is forcing systemd-journald to rotate the active binary log file into archived status. This ensures recent entries are marked for cleanup and avoids lingering open file descriptors:
sudo journalctl --rotate
sudo journalctl --vacuum-size=500M

Safety warning: Never run
rm -rf /var/log/journal/*manually while systemd is running. Manually deleting log files withrmbypasses the systemd daemon, causing metadata corruption, leaving orphan open file handles, and preventing new logs from being written until the system is rebooted.
Conclusion
Proactively managing Linux storage is what separates a stable infrastructure from an unexpected production outage. Learning how to configure journald gives you precise control over log retention, keeping systemd-journald lean and efficient without wasting disk space. By combining drop-in configuration files under /etc/systemd/journald.conf.d/ with sensible caps like SystemMaxUse, SystemMaxFileSize, and MaxRetentionSec, you ensure that your servers and development workstations always retain enough diagnostic history to troubleshoot incidents while protecting your root partition and NVMe SSD longevity for the long run.