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: dmesg -F reads a saved kernel log from a file, with the usual filters

Dmesg
~/tips/tip-dmesg-read-saved-file

sudo dmesg -r > kernel.raw

Save raw kernel messages on one machine and study them on another.

Someone sends you a dump of the kernel log, or you grab one from a sick server before restarting it. You can run the normal dmesg filters on that file.

Save the buffer in raw form, which keeps the level markers on each line:

sudo dmesg -r > kernel.raw

Then read it back, on the same machine or a different one:

dmesg -F kernel.raw --level=err,warn
dmesg -F kernel.raw -x | less

No sudo is needed for reading a file. The -r on the way out is the important part. Without it the levels are stripped, and the level and facility filters have nothing to work with.

I like it for bug reports. One file holds everything, and the person reading it can slice it however they want.

The man page notes that -F does not read the kmsg format, so a file copied straight from /dev/kmsg will not work. Use the output of dmesg -r. Also look through the file before you send it anywhere. Kernel messages can contain MAC addresses, disk serial numbers, device names and sometimes program names with their arguments, which you may not want to post in a public forum.

Further reading: dmesg man page

More Dmesg tips sudo dmesg -C sudo dmesg -x sudo dmesg -n 4 sudo dmesg -T | tail -30 All Dmesg tips (5) All topics

Link