Save GBs 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 no new packages were installed. On modern distributions like Debian 13.7 and Ubuntu 26.04.1, one of the primary silent culprits behind this excessive storage consumption is systemd's native log collector. Knowing how to configure journald is an essential skill for any software engineer or system administrator looking to keep their system stable, predictable, and free from sudden disk space exhaustion.
systemd-journald is a system daemon responsible for capturing stdout, stderr, syslog, and kernel messages from all processes managed by systemd. It centralizes diagnostic information into indexed binary files, making log queries 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 filesystem's total capacity or up to 4 GB of persistent storage. On a web server or in a development environment running high-traffic containers and microservices, this default cap can be reached in just a few weeks, eating up dozens of gigabytes that should be reserved for databases and application workloads.
Why Does /var/log/journal Keep Growing?
The unchecked growth of the /var/log/journal directory stems from how systemd-journald handles log file lifecycles. By default, the service creates structured binary log files under a directory named with the machine's unique Machine ID (/etc/machine-id). Unlike traditional plain-text log files managed by legacy tools like logrotate, journald logs maintain internal indices to ensure ultra-fast lookups by metadata such as UID, PID, and systemd unit.

When a service continuously writes logs, the active log file reaches a predefined size limit, closes, and rotates into an archived status. If no explicit quota rules are configured, journald keeps creating new files until it hits the global limit calculated against the partition's capacity. On production servers with 500 GB or 1 TB NVMe drives, a 10% default cap can hoard 50 GB to 100 GB of historical log data without any real operational need.
In addition, services caught in crash loops, Python applications dumping massive 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 (stored on disk under /var/log/journal) is the first step toward taking control of your log retention policy.
How to Diagnose Disk Space Used by journalctl Logs
Before modifying any configuration files, you need to measure the exact amount of disk space journald logs consume on your system's SSD or hard drive. The systemd ecosystem provides native tools for this audit.
The primary command for checking journal storage footprint is journalctl --disk-usage. Running it in your terminal scans the storage directory and returns the total space consumed by active and archived files:
journalctl --disk-usage
The output of this command will display a message similar to:
Archived and active journals take up 4.2G in the file system.
To get a detailed view of individual files and check for potential file corruption or bloated logs, you can directly inspect the destination directory using standard Linux shell utilities:
sudo du -sh /var/log/journal/*
sudo ls -lh /var/log/journal/$(cat /etc/machine-id)
Another useful check is inspecting the header of log instances to understand the time window these files cover. By running journalctl --header, the system displays the timestamp bounds of the first and last records in the active file, helping you identify whether you are keeping unnecessary logs from six months ago.
Step-by-Step: How to Configure journald to Control Disk Usage
The recommended way to customize systemd-journald behavior is not to edit the main /etc/systemd/journald.conf file directly, as OS updates can overwrite it. Instead, modern Linux best practices dictate using drop-in configuration files inside /etc/systemd/journald.conf.d/.
Follow these steps to apply strict, safe limits on storage consumption:
1. Create the Custom Configuration Directory
Open your terminal with administrative 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 Override 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 Storage Quota Parameters
Insert the configuration block below into the file. These directives instruct systemd to keep logs persistent on disk while setting strict caps on maximum global space, required free disk headroom, and individual file sizes:
[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 under/var/log/journaland persist across system reboots.SystemMaxUse=1G: Sets the absolute maximum disk space that all log files combined can consume on the filesystem. In this example, logs are capped at 1 Gigabyte.SystemKeepFree=2G: Guarantees that journald will stop consuming disk space if the partition has less than 2 Gigabytes of free space remaining.SystemMaxFileSize=100M: Restricts the size of each binary log file to 100 Megabytes. Once reached, the file rotates.SystemMaxFiles=10: Limits the total number of retained log files (active and archived) to a maximum of 10.
4. Validate and Apply the Changes
After saving and closing the file, verify the configuration syntax and restart the systemd-journald service to apply the new rules immediately:
sudo systemd-analyze cat journald.conf
sudo systemctl restart systemd-journald
Recheck disk consumption using journalctl --disk-usage. Systemd will immediately trigger an automatic cleanup to bring log storage within your newly defined thresholds.
How to Apply Time and File Limits in journald.conf
Beyond setting byte- and megabyte-based quotas, setting time-based log retention limits is crucial. In many compliance-driven environments or local development servers, keeping logs older than 14 or 30 days is unnecessary and wastes disk space.
The table below summarizes key time and rate-limiting directives available in journald.conf to optimize your retention strategy:
| Directive | Behavior Description | Recommended Value | Use Case |
|---|---|---|---|
MaxRetentionSec |
Absolute maximum time to retain any log record. | 14d or 1month |
General web servers and APIs |
MaxFileSec |
Maximum lifespan of a single active log file before rotation. | 1day |
Moderate traffic environments |
RateLimitIntervalSec |
Time window for monitoring extreme log bursts. | 30s |
Crash loop protection |
RateLimitBurst |
Maximum allowed log entries within the time window. | 10000 |
Log-based denial of service prevention |
To enforce a 14-day temporal retention limit and guard against noisy services, update your /etc/systemd/journald.conf.d/00-storage-limit.conf file with these time parameters:
[Journal]
Storage=persistent
SystemMaxUse=1G
SystemKeepFree=2G
SystemMaxFileSize=100M
MaxRetentionSec=14d
RateLimitIntervalSec=30s
RateLimitBurst=10000
The RateLimitBurst parameter prevents runaway application errors—such as a Python app stuck in an unhandled exception loop—from swamping disk I/O by attempting to write hundreds of thousands of log lines per second.
How to Manually Clean journald Without Rebooting
If your server's partition is already at 100% capacity and you need to reclaim emergency space before applying permanent config files, journalctl provides quick cleanup flags known as vacuuming parameters.
You can perform emergency log vacuuming based on size, age, or file count without interrupting the operating system or affecting running applications.
To immediately shrink total journal disk usage down to a fixed target, use the --vacuum-size flag:
sudo journalctl --vacuum-size=500M
To delete log files recorded more than a week ago, use the --vacuum-time flag:
sudo journalctl --vacuum-time=7d
If you prefer to cap the sheer number of archived files, use --vacuum-files:
sudo journalctl --vacuum-files=5
Before running any vacuum command, an important advanced technique is forcing systemd-journald to rotate the active binary log file into an archived file. This guarantees that all recent log history is eligible for vacuuming without sticking to open file descriptors:
sudo journalctl --rotate
sudo journalctl --vacuum-size=500M

Safety warning: Never manually run
rm -rf /var/log/journal/*while the systemd daemon is running. Deleting log files directly withrmwithout notifying the daemon can corrupt metadata catalogs, leave open file descriptors pointing to orphaned blocks, and prevent new log entries from being written until the next system reboot.
Conclusion
Proactively managing Linux server storage makes all the difference between stable infrastructure and an unplanned production outage. Understanding how to configure journald lets you fine-tune log retention with surgical precision, ensuring systemd-journald retains only what you need for debugging without devouring disk space.
By setting hard caps with SystemMaxUse, enforcing time-based retention with MaxRetentionSec, and using drop-in config files under /etc/systemd/journald.conf.d/, you make log maintenance on Debian 13.7 and Ubuntu 26.04.1 automated and predictable. Bake these directives into your server base images to eliminate log-induced full disk panics once and for all.