Nie wiem jaki chory umysł wpadł na pomysł, aby domyślnie journald w niektórych dystrybucjach (np. Ubuntu) nie persystował logów na dysku, ale uważam to za dość problematyczne zachowanie – w przypadku awarii bardzo ciężko dojść co właściwie się stało przed restartem systemu.
W tym wpisie zmienimy to domyślne zachowanie.
Sprawa jest prosta:
mkdir /var/log/journal systemd-tmpfiles --create --prefix /var/log/journal systemctl restart systemd-journald
I już :) Możemy testowo zrestartować komputer i zobaczyć, że logi z poprzedniego uruchomienia są dostępne:
journalctl --boot=-1
Jeśli nie zadziała to warto rzucić okiem na ustawienia w /etc/systemd/journald.conf i sprawdzić czy opcja Storage jest ustawiona na auto lub persistent.
Pozostaje pytanie, czy logi nie zjedzą nam całego wolnego miejsca na dysku, man twierdzi, że nie:
SystemMaxUse= and RuntimeMaxUse= control how much disk space the journal may use up at maximum. SystemKeepFree= and RuntimeKeepFree= control how much disk space systemd-journald shall leave free for other uses. systemd-journald will respect both
limits and use the smaller of the two values.The first pair defaults to 10% and the second to 15% of the size of the respective file system, but each value is capped to 4G. If the file system is nearly full and either SystemKeepFree= or RuntimeKeepFree= is violated when systemd-journald is started, the value will be raised to percentage that is actually free. This means that if there was enough free space before and journal files were created, and subsequently something else causes the file system to fill up, journald will stop using more space, but it will not be removing existing files to go reduce footprint either.
A więc nie ma się czego obawiać :)
Dodaj komentarz