Linux

systemd Journal Disk Usage: Inspect Retention and Safely Vacuum Archived Logs

The Back Room Tech Staff · Edited by Aseem Kishore
15 min read

The Back Room Tech is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

Measure journal disk use, save required records, then clear archives within approved limits. Start on a Linux host running systemd-journald, and check its installed systemd version before running these commands.

You can undo a retention drop-in. Deleted records stay deleted when you change the settings back.

TaskCommand or controlImportant limit
Measure journal storagejournalctl --disk-usageIncludes active and archived files
Inspect journal headersjournalctl --headerShows file metadata for the selected scope, not all host directories
Remove eligible archivesjournalctl --vacuum-sizeDoesn’t cap total journal usage
Make active files eligiblejournalctl --rotateChanges what later cleanup can delete
Set ongoing retentionjournald.conf drop-inRequires separate persistent and runtime choices
Inspect configuration sourcessystemd-analyze cat-configReads config files, not live daemon state

Check systemd, journal scope, and retention prerequisites

1. Confirm the host and installed options

Use an existing Linux server with SSH or terminal access, Bash, and approved admin access. You don’t need a separate journal-cleanup app. On Ubuntu or Debian, the systemd tools normally come with the system.

Run:

cat /etc/os-release
hostname
systemctl --version
systemctl is-active systemd-journald.service

Expect your distro details, hostname, installed systemd version, and an active service result. Record the actual versions in your maintenance notes. No tested distro build is claimed here.

If this host doesn’t run systemd-journald, stop here. Installing a replacement logging stack falls outside this workflow.

Check the local manuals:

man journalctl
man journald.conf
man systemd-journald.service
man systemd-analyze

In each manual, press /, enter a term, and press Enter. Press n for the next match and q to quit.

Check these options and settings before you proceed:

  • In journalctl: --directory, --namespace, --header, --disk-usage, --output, --rotate, and --vacuum.
  • In journald.conf: Storage, SystemMaxUse, RuntimeMaxUse, file-size limits, file-count limits, and drop-in precedence.
  • In systemd-analyze: cat-config.

The official journalctl manual describes these tasks. Use your installed manual to check which syntax the host supports.

Installed OS and systemd version alongside locally documented journalctl vacuum and rotation options

Define the cleanup scope before you measure:

Scope itemRecord this
HostHostname and environment
Journal namespaceDefault namespace or an explicitly named namespace
SourceExact journal directory or directories
Account coverageSystem journals and any user journals within that source
ProtectionRequired audit records, incident records, and retention obligations
AuthorizationApproved cleanup criteria and maintenance window

Don’t assume default-namespace commands include other namespaces. Namespaced journal services have their own config and storage needs. See systemd-journald.service.

The commands below target one confirmed directory in the default namespace. Repeat measurement and preservation for each extra directory in scope. For a named namespace, check its service instance, source paths, and config filename locally before adapting the service commands.

Warning: Get local retention approval before vacuuming or applying tighter automatic limits. Preserve protected records first. Both actions can cause permanent deletion.

Measure systemd journal disk usage against filesystem capacity

2. Identify the files, then measure the same source consistently

Start by listing journal directories and files directly on the filesystem in read-only mode:

sudo find /var/log/journal /run/log/journal -mindepth 1 -maxdepth 1 -type d 
sudo find /var/log/journal /run/log/journal -maxdepth 2 -type f -name '*.journal' -exec stat -c '%n (%s bytes)' {} + 

Persistent journals typically live under /var/log/journal/<machine-id> and volatile runtime journals under /run/log/journal/<machine-id>. Named namespaces appear in separate <machine-id>.<namespace> subdirectories.

A host can use both roots at once: runtime files under /run until journald flushes them to persistent storage, and persistent files under /var. journald keeps writing to /run until it switches to persistent storage, which happens after sudo journalctl --flush (or at boot once /var/log/journal is available and Storage= allows persistence).

Changing Storage= settings doesn’t move existing runtime files by itself. Each directory you pick covers one storage location only, so measuring and cleaning /var/log/journal/<machine-id> says nothing about /run/log/journal/<machine-id> or a namespace directory. Repeat the steps for every directory the earlier find listed that falls inside your approved scope.

Presence varies by host configuration, so confirm storage paths in your local systemd-journald.service manual if neither root appears. Don’t rely on journalctl --header to discover directories on disk; it displays header metadata for the currently selected reading scope rather than listing all journal paths.

Enter one exact subdirectory that directly contains the .journal files you want to inspect. --directory expects that specific journal directory, not a broad parent such as /var/log/journal or an unverified path from header output:

read -r -p "Exact journal directory to inspect: " JOURNAL_DIR
sudo test -d "$JOURNAL_DIR"
JOURNAL_SOURCE=(--directory="$JOURNAL_DIR")

Continue only if the directory check succeeds. Run every block in Bash, not sh, because the steps use a Bash array (JOURNAL_SOURCE), and keep using the same session so the variables stay available.

Measure that directory and inspect its file headers:

printf 'Selected journal directory: %s\n' "$JOURNAL_DIR"
sudo journalctl "${JOURNAL_SOURCE[@]}" --header --no-pager
sudo journalctl "${JOURNAL_SOURCE[@]}" --disk-usage
sudo du -sh "$JOURNAL_DIR"
df -h "$JOURNAL_DIR"

--directory selects which journal directory journalctl opens for the reads below. Expect header metadata for files in that directory, a journal usage total, directory usage, and filesystem capacity.

The usage line follows this format, with your own size:

Archived and active journals take up 1.8G in the file system.

The journal total includes active and archived journal files. df reports the whole filesystem, including other data. du measures the selected directory, so its number can differ from journal accounting.

Don’t treat the journal total as space you can reclaim. The journalctl manual explains the difference between total usage and archived-file vacuuming.

Save these baseline results in your maintenance record. Note the directory alongside every number.

Exact selected default-namespace journal directory, journalctl disk usage, du output, and df capacity for that same directory

Preserve required journal records before cleanup

3. Create and verify the policy-approved preservation copy

Decide which records must survive, which dates and times bound that need, and which format your recovery process accepts.

A readable export helps with review. It doesn’t automatically replace original journal files, structured metadata, or an approved forensic copy. If policy requires those, complete that process before you continue.

A text export such as short-iso keeps the timestamp, host, identifier, and message, but drops most structured journal fields (for example _SYSTEMD_UNIT, _BOOT_ID, and _PID as separate fields) and it doesn’t carry the original journal’s Forward Secure Sealing metadata. You can’t filter it later with journalctl matches or check it with journalctl --verify. If you may need those, copy the original .journal files or use --output=export instead, and only use the text copy below when policy explicitly accepts it.

If policy accepts a human-readable copy, choose a protected destination with enough space. An external SSD or NAS share can keep the copy off the filesystem you’re cleaning. But you’ll have another place to manage access and backups.

Create a restricted working directory:

read -r -p "Existing protected preservation destination: " PRESERVE_ROOT
test -d "$PRESERVE_ROOT"
test -w "$PRESERVE_ROOT" || echo "Not writable by $(id -un); pick a destination your account can write to"
df -h "$PRESERVE_ROOT"
umask 077
PRESERVE_DIR=$(mktemp -d "$PRESERVE_ROOT/journal-preserve.XXXXXXXX")
printf 'Preservation directory: %s\n' "$PRESERVE_DIR"

Continue only after you confirm the destination exists, is writable by your own account, and has enough space. mktemp runs as your normal user, so PRESERVE_DIR ends up owned by you. That matters in the next step: sudo elevates only journalctl, while the > redirection is performed by your unprivileged shell. If your only approved destination is root-writable, replace > "$PRESERVE_DIR/required-records.txt" with | sudo tee "$PRESERVE_DIR/required-records.txt" > /dev/null.

Enter the approved time window with an explicit timezone. For example, the input format can be 2026-12-01 00:00:00 UTC; use your actual required dates.

read -r -p "Required start timestamp, including timezone: " KEEP_SINCE
read -r -p "Required end timestamp, including timezone: " KEEP_UNTIL

sudo journalctl "${JOURNAL_SOURCE[@]}" \
  --since="$KEEP_SINCE" \
  --until="$KEEP_UNTIL" \
  --output=short-iso \
  --no-pager > "$PRESERVE_DIR/required-records.txt"

--since and --until bound the exported records. --no-pager bypasses the pager, and > sends the output to the file. Check supported output formats in the journalctl documentation.

Verify the copy:

test -s "$PRESERVE_DIR/required-records.txt"
less "$PRESERVE_DIR/required-records.txt"

Inside less, inspect the beginning, press G for the end, and search for known required events using /. Press q to exit.

Expect readable records that cover the required sources and time window. A nonempty file alone doesn’t prove the copy is complete. Match known event timestamps and identifiers against the source.

Record the scope and checksum:

printf 'Host: %s\nDirectory: %s\nSince: %s\nUntil: %s\n' \
  "$(hostname)" "$JOURNAL_DIR" "$KEEP_SINCE" "$KEEP_UNTIL" \
  > "$PRESERVE_DIR/scope.txt"

sha256sum "$PRESERVE_DIR/required-records.txt" \
  > "$PRESERVE_DIR/required-records.sha256"

sha256sum --check "$PRESERVE_DIR/required-records.sha256"

The checksum check should report OK. It detects later changes to the export. It doesn’t prove that you captured every required record.

Stop if required records are missing or the preservation format isn’t approved. Apply your retention and access rules to the saved copy too.

Preservation scope, readable required records, and successful checksum verification with sensitive content redacted

Vacuum eligible archived journals and control rotation

4. Apply only the approved cleanup criterion

Vacuuming deletes whole archived files. It doesn’t remove selected messages inside a file.

OptionCleanup criterionConsequence
--vacuum-size=Archived-file storage targetActive files remain outside deletion
--vacuum-time=Age threshold for archived filesDoesn’t establish minimum retention
--vacuum-files=Archived-file count targetRemaining files can vary in size

All three options act only on archived files; active files are excluded unless you rotate them first. --vacuum-time= itself removes archived files older than the timespan you give. If you combine options in one command, journalctl enforces every limit you specified, so an age threshold doesn’t protect younger archives from a stricter size or count limit. See the official vacuum option descriptions.

There’s no universal safe budget. Choose one based on measured capacity, log volume, preservation needs, and approved retention policy.

Warning: The next command permanently removes eligible archived journal files from the selected directory. Configuration rollback can’t recover them.

For an approved archived-size target:

read -r -p "Approved archived-size target, using local journalctl syntax: " VACUUM_SIZE
sudo journalctl "${JOURNAL_SOURCE[@]}" --vacuum-size="$VACUUM_SIZE"
sudo journalctl "${JOURNAL_SOURCE[@]}" --disk-usage
df -h "$JOURNAL_DIR"

The manual documents --directory as a source selector and the vacuum options as limits on archived files, but it doesn’t explicitly promise that vacuuming stays inside the selected directory on every systemd version. Treat the output as your scope check: every Deleted archived journal line should name a file inside $JOURNAL_DIR.

If any line names another path, stop, record it, and review the remaining cleanup with your approver before running further vacuum commands. If your policy requires guaranteed single-directory isolation before deletion, don’t vacuum until you’ve confirmed this behavior on a non-production host with the same systemd version.

Expect the vacuum summary to report reclaimed space, possibly zero. Its last line follows this format:

Vacuuming done, freed 384.0M of archived journals from /var/log/journal/<machine-id>.

Keep that result with the baseline.

If approval instead specifies age, use:

read -r -p "Approved maximum archive age, using local journalctl syntax: " VACUUM_TIME
sudo journalctl "${JOURNAL_SOURCE[@]}" --vacuum-time="$VACUUM_TIME"

For an approved archived-file count:

read -r -p "Approved archived-file count: " VACUUM_FILES
sudo journalctl "${JOURNAL_SOURCE[@]}" --vacuum-files="$VACUUM_FILES"

Choose the approved operation. Don’t run all three alternatives by habit.

Rotation needs a separate decision. It turns active files into archives, so later cleanup can delete more records.

For the confirmed default namespace, and only after checking local --rotate behavior:

sudo journalctl --rotate

This command asks the running journald service to rotate. It isn’t scoped by --directory, so default-namespace rotation can archive active files in every directory that service writes to, not just your selected one. After rotation, the whole workflow is no longer confined to one directory: more files become eligible for any later vacuum.

I’d skip rotation unless reclaiming those extra files is necessary and approved. After rotation, inspect the selected source again before rerunning the approved vacuum command:

sudo journalctl "${JOURNAL_SOURCE[@]}" --header --no-pager
sudo journalctl "${JOURNAL_SOURCE[@]}" --disk-usage
Policy-approved vacuum command, actual reclaimed-space summary, and subsequent usage for the identical selected directory

Configure separate persistent and runtime retention limits

5. Add one identifiable retention drop-in

Inspect config sources before changing anything:

sudo systemd-analyze cat-config systemd/journald.conf

This prints the main file and applicable drop-ins in config order. It doesn’t query the daemon’s live internal state. See systemd-analyze.

Save the assembled config:

sudo systemd-analyze cat-config systemd/journald.conf \
  > "$PRESERVE_DIR/journald-config-before.txt"

You can also inspect the main file and drop-in paths listed in the installed journald.conf manual directly.

Use these settings only after you confirm local support:

Persistent storageRuntime storagePurpose
SystemMaxUseRuntimeMaxUseStorage usage limit
SystemKeepFreeRuntimeKeepFreeSpace journald should leave free
SystemMaxFileSizeRuntimeMaxFileSizeIndividual file size
SystemMaxFilesRuntimeMaxFilesFile-count limit

Persistent settings govern persistent journal storage. Runtime settings govern volatile journal storage. Active files and whole-file deletion can keep usage from matching a set limit exactly.

Storage selects a storage mode. It doesn’t accept an arbitrary directory path. Check its effective value before deciding whether logs should survive reboot.

MaxRetentionSec limits retention age, while MaxFileSec controls time-based rotation. Neither guarantees a minimum history when other limits require earlier deletion. The journald.conf manual explains how these settings interact.

Enter locally approved values. Size values and positive file counts must use syntax accepted by your installed manual:

read -r -p "Approved SystemMaxUse: " SYSTEM_MAX_USE
read -r -p "Approved SystemMaxFileSize: " SYSTEM_MAX_FILE_SIZE
read -r -p "Approved SystemMaxFiles: " SYSTEM_MAX_FILES
read -r -p "Approved RuntimeMaxUse: " RUNTIME_MAX_USE
read -r -p "Approved RuntimeMaxFileSize: " RUNTIME_MAX_FILE_SIZE
read -r -p "Approved RuntimeMaxFiles: " RUNTIME_MAX_FILES

Create the drop-in only if this tutorial’s filename is unused:

sudo install -d -m 0755 /etc/systemd/journald.conf.d

if sudo test -e /etc/systemd/journald.conf.d/90-tbrt-retention.conf; then
  printf 'File already exists; inspect it before proceeding.\n'
else
  # /etc/systemd/journald.conf.d/90-tbrt-retention.conf
  sudo tee /etc/systemd/journald.conf.d/90-tbrt-retention.conf > /dev/null <<EOF
[Journal]
# Persistent journal storage
SystemMaxUse=$SYSTEM_MAX_USE
SystemMaxFileSize=$SYSTEM_MAX_FILE_SIZE
SystemMaxFiles=$SYSTEM_MAX_FILES

# Volatile runtime journal storage
RuntimeMaxUse=$RUNTIME_MAX_USE
RuntimeMaxFileSize=$RUNTIME_MAX_FILE_SIZE
RuntimeMaxFiles=$RUNTIME_MAX_FILES
EOF
fi

This leaves the existing storage mode unchanged. Review the file and assembled config:

sudo cat /etc/systemd/journald.conf.d/90-tbrt-retention.conf
sudo systemd-analyze cat-config systemd/journald.conf

Check for later overrides. Drop-in filenames affect precedence. A 90- prefix doesn’t guarantee the last assignment.

Warning: Applying tighter retention can trigger further deletion. Confirm preservation and approval before reloading the journal service.

systemd-journald reloads its configuration on SIGHUP, so avoid a disruptive full service restart. Reload the default-namespace service where your installed unit supports reload, then verify its status:

sudo systemctl reload systemd-journald.service
systemctl is-active systemd-journald.service

If your systemd version reports that reload isn’t supported for systemd-journald.service, send SIGHUP directly to the main process instead and verify that the service remains active:

sudo systemctl kill --signal=SIGHUP --kill-who=main systemd-journald.service
systemctl is-active systemd-journald.service

Expect active. Editing a journald.conf drop-in doesn’t require systemctl daemon-reload, which applies to systemd unit files rather than journald configuration, only the journald reload above is needed.

Tutorial-created drop-in with persistent and runtime sections plus assembled configuration showing applicable overrides

Verify retained records and reverse the configuration safely

6. Compare the original scope and keep rollback explicit

Repeat the original measurements:

sudo journalctl "${JOURNAL_SOURCE[@]}" --disk-usage
sudo du -sh "$JOURNAL_DIR"
df -h "$JOURNAL_DIR"
sudo systemd-analyze cat-config systemd/journald.conf
systemctl is-active systemd-journald.service

Check recent records and any required retained window:

sudo journalctl "${JOURNAL_SOURCE[@]}" --lines=20 --no-pager

sudo journalctl "${JOURNAL_SOURCE[@]}" \
  --since="$KEEP_SINCE" \
  --until="$KEEP_UNTIL" \
  --no-pager

sha256sum --check "$PRESERVE_DIR/required-records.sha256"

Compare the results with your approved outcome. Records you chose to remove locally should remain available through the approved preservation method.

Use these checks when results differ:

SymptomCause to checkAction
Usage exceeds --vacuum-sizeActive files remain includedRun --header and --disk-usage for the same directory; review rotation separately
Vacuum reclaims zero bytesNo archives meet the selected criterionConfirm directory, file headers, and approved threshold
Permission deniedAccount lacks required accessRepeat through an authorized administrative account using sudo
Logs disappear after rebootRuntime storage or storage-mode configurationInspect Storage, directory paths, and persistent-storage prerequisites
Retention appears ineffectiveLater override or wrong storage classInspect assembled configuration and compare System* versus Runtime* settings

Don’t compensate for disappointing results by deleting live journal files manually.

To reverse only the tutorial-created config, move its drop-in outside the config directory and reload systemd-journald:

sudo mv /etc/systemd/journald.conf.d/90-tbrt-retention.conf \
  "$PRESERVE_DIR/90-tbrt-retention.conf.disabled"

sudo systemctl reload systemd-journald.service
systemctl is-active systemd-journald.service
sudo systemd-analyze cat-config systemd/journald.conf
sudo journalctl "${JOURNAL_SOURCE[@]}" --disk-usage

If your host doesn’t support systemctl reload for this unit, replace the reload line with sudo systemctl kill --signal=SIGHUP --kill-who=main systemd-journald.service. As before, systemctl daemon-reload isn’t needed.

Expect the tutorial drop-in to disappear from the assembled config. Earlier settings and defaults apply again, assuming no other config changed.

Rollback changes future retention behavior. It can’t restore vacuumed records. Recover those through the verified preservation copy and your recovery process.

Post-change journal measurements for the original directory, the active journald service, and the merged configuration

Wrapping Up

Tie each cleanup to a documented source, measured storage, and a verified preservation copy.

StepActionApplies To
1Confirm version, scope, and approvalTarget host and namespace
2Measure journal and filesystem usageExact journal directory
3Preserve and verify required recordsApproved sources and time window
4Vacuum eligible archivesApproved cleanup scope
5Apply a documented drop-inCorrect journald service instance
6Verify results and retain rollbackConfiguration and preservation copy

I’d keep the drop-in and approval record together. Review capacity before tightening limits again.