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 /dev/sda shows kernel messages about one disk

Journalctl
~/tips/tip-journalctl-device-node-match

journalctl /dev/sda

Shows only the journal entries about one device, such as a failing disk, for the current boot.

When a disk starts to misbehave, the kernel log is where the story is, and I want only the lines about that disk.

Give journalctl a device node and it adds _KERNEL_DEVICE= matches for the device and its parents. That pulls out the messages the kernel wrote about that disk, and its parent devices.

journalctl /dev/sda

Device nodes can point to a different physical disk after a reboot, so journalctl restricts the output to the current boot. For an older boot you need another approach, such as a text search with -g.

Further reading: journalctl(1) manual 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