brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl relinquish-var lets you unmount /var without losing logs

Journalctl
~/tips/tip-journalctl-relinquish-var

sudo journalctl --relinquish-var

Make journald stop writing to /var so the disk can be unmounted cleanly.

Moving /var to another disk or running a check on it fails as long as journald keeps its files open there. There is an option for exactly that.

--relinquish-var is the reverse of --flush. journald closes its files under /var/log/journal and goes back to writing in /run/log/journal, in memory:

sudo journalctl --relinquish-var
sudo umount /var

A new system.journal appears under /run/log/journal straight away and logging keeps working. Once the disk is back, send everything to persistent storage again:

sudo mount /var
sudo journalctl --flush

There is also --smart-relinquish-var. It does the same, but does nothing when /var/log/journal sits on the root file system, since then there is no separate mount to free. systemd uses that one during shutdown.

While you are relinquished, lines live in RAM only. A crash or power cut in that window takes them with it, and RuntimeMaxUse= caps how much is kept. I would flush back to disk as soon as the job is done; other processes may still hold /var open, so check with fuser -vm /var if the unmount refuses.

Further reading: journalctl man page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link