When running low on storage space on Ubuntu, users often clean their APT package cache or remove old snap packages. However, an overlooked consumer of storage on systems that have been running for several months is the systemd-journald logging service. Over time, binary system logs stored inside /var/log/journal/ can silently expand to consume 4 GB, 8 GB, or even 15 GB of root partition space.
While maintaining log records is vital for diagnosing past system crashes, hardware faults, and service failures, retaining years of routine operating system events is rarely necessary for everyday desktop users. Ubuntu provides dedicated management commands through journalctl that allow you to safely vacuum historical logs and enforce permanent storage caps without compromising ongoing system monitoring.
Check Your Current Journal Disk Usage
Before deleting any log files, check exactly how much storage space the systemd journal is currently occupying on your root filesystem. Open your terminal (press Ctrl + Alt + T) and run:
journalctl --disk-usage
The terminal will output the current footprint, such as: Archived and active journals take up 6.2G in the file system. If this number exceeds 1 GB on a standard workstation, trimming the archive will immediately reclaim valuable storage.
Step 1: Rotate Active Logs Before Vacuuming
Systemd cannot safely trim or vacuum active log files that are currently being written to by the journal daemon. To ensure all active journals are marked as archived and ready for cleanup, issue the rotate command first:
sudo journalctl --rotate
This command closes active journal files and starts fresh, empty instances, allowing historical archives to be deleted cleanly without triggering write lock warnings.
Step 2: Vacuum Logs by Time Window
If you prefer to maintain a rolling window of recent diagnostic logs (for instance, the past 3 or 7 days) and purge everything older, use the --vacuum-time parameter:
sudo journalctl --vacuum-time=3d
You can adjust the time parameter to your preferred retention window using standard units:
2d: Retains only the last 2 days of logs.1w: Retains logs from the past week.1months: Retains logs from the past month.
The utility will output the number of archived files deleted and the exact amount of disk space freed.
Step 3: Vacuum Logs by Maximum Disk Size
If storage space is at a premium and you want to ensure journal archives do not exceed a specific size threshold (such as 500 MB), use the --vacuum-size parameter:
sudo journalctl --vacuum-size=500M
Systemd will inspect all archived journal files on disk, sort them chronologically, and delete the oldest entries until the total aggregate size falls below your specified limit (e.g. 500M or 1G).
Step 4: Enforce Permanent Size Caps in journald.conf
Vacuuming logs with journalctl is an effective immediate fix, but the journal will gradually grow again over subsequent weeks. To prevent the journal from ever exceeding a reasonable threshold, configure a permanent maximum size cap in the daemon’s configuration file.
- Open the journal configuration file in your text editor:
sudo nano /etc/systemd/journald.conf - Look for the line containing
#SystemMaxUse=under the[Journal]header. - Remove the leading
#character to uncomment the directive and set your desired maximum limit (for example, 500 megabytes):SystemMaxUse=500M - Optionally, uncomment and set
SystemKeepFree=1Gto ensure the journal never consumes space if your root partition has less than 1 GB of free storage remaining. - Press Ctrl + O and Enter to save, then Ctrl + X to exit.
- Restart the journal daemon to apply your permanent rules:
sudo systemctl restart systemd-journald
Journal Vacuum Command Reference
The table below provides a quick reference for managing systemd journal storage on Ubuntu:
| Command | Operation | Primary Scenario |
|---|---|---|
journalctl --disk-usage |
Reports storage consumption | Triage when investigating full disk alerts |
sudo journalctl --rotate |
Archives active log files | Prerequisite before running vacuum commands |
sudo journalctl --vacuum-time=3d |
Purges logs older than N days | Preserving recent logs while freeing old space |
sudo journalctl --vacuum-size=500M |
Caps total archived log size | Strict storage constraints on SSD partitions |
/etc/systemd/journald.conf |
Configures daemon limits | Permanent automation preventing future log bloat |
Verifying Reclaimed Storage
After vacuuming your logs and restarting the daemon, run journalctl --disk-usage and df -h / to confirm that your root partition has regained its free capacity. Enforcing a permanent 500 MB limit ensures your Ubuntu system maintains comprehensive troubleshooting logs without cluttering your hard drive.