Skip to content

View Previous Boot Logs on Raspberry Pi

Run sudo journalctl -b -1 to read the previous retained boot after a crash or bad shutdown. If that command has no previous boot to read, check which boots were saved and where Raspberry Pi OS stores the journal.

Find the boot that had the problem

Run these on the Pi. Use the timestamps in the first command to identify the boot where the problem occurred.

1
2
3
# List retained boots and show the last 100 entries from the previous one.
sudo journalctl --list-boots --no-pager
sudo journalctl -b -1 --no-pager -n 100

0 is the current boot, and -1 is the previous boot in the journal. After another reboot, you can use the BOOT ID from the list in place of -1 to return to the same log. journalctl boot selection

1
2
3
4
5
# Show kernel messages from the previous boot.
sudo journalctl -b -1 -k --no-pager -n 80

# Show one service from the previous boot. Replace ssh.service as needed.
sudo journalctl -b -1 -u ssh.service --no-pager -n 80

Use the kernel view for disk, USB or power messages. Use the service view when one app or service failed to start. Remove -n 80 if you need to read earlier entries. On a Pi 4B, these filters retrieved the matching entries from a test journal that contained two boot IDs.

If journalctl only shows the current boot

Check with sudo so you can see the system journal. If only boot 0 appears, inspect the combined configuration, including the Raspberry Pi OS drop-ins.

systemd-analyze cat-config systemd/journald.conf
findmnt -T /var/log -o TARGET,SOURCE,FSTYPE,OPTIONS

On the tested Pi 4B with Trixie, journalctl -b -1 reported no persistent journal was found. The raspberrypi-sys-mods package supplied 40-rpi-volatile-storage.conf with Storage=volatile. Journal files were under /run/log/journal even though /var/log/journal existed. With volatile storage, the journal is kept in memory and each reboot starts a new history. If persistent storage is already configured, check whether /var/log sits on a temporary overlay or older logs have rotated out. systemd journal storage settings · Raspberry Pi OverlayFS checks

Keep logs for the next reboot

On Raspberry Pi OS versions with the logging menu, open sudo raspi-config and select Advanced Options → Logging → Persistent. On the tested version, this creates an administrator drop-in that sets Storage=persistent.

If that menu is unavailable, create the directory with sudo mkdir -p /etc/systemd/journald.conf.d, then use sudoedit to put these lines in /etc/systemd/journald.conf.d/90-persistent-journal.conf:

[Journal]
Storage=persistent

On a system with writable persistent storage, apply the change and flush the current journal to disk. Confirm that your current boot appears in the persistent journal directory.

1
2
3
4
sudo systemctl restart systemd-journald.service
sudo journalctl --flush
machine_id=$(cat /etc/machine-id)
sudo journalctl --directory "/var/log/journal/$machine_id" --list-boots --no-pager

After your next planned reboot, run sudo journalctl --list-boots and check that the earlier boot is still present. Persistent storage keeps the current and future journal entries on disk. For an incident from before the saved journal begins, look for app-specific logs or a copy retained elsewhere. To manage disk use, set retention for the persistent journal. Limit journal disk use · systemd journal service

Donate