In order to debug kernel panic/freeze cases on devices which do not have serial console exposed, we can use Linux kernel’s netconsole module. This module is created with exactly this case in mind.
In order to use the, we need to configure it first. Configuration can be done both via kernel paraketers or via insmod/modprobe cli.
# Here 10.69.7.12 is target ip to which messages are sent via udp (by default port 6666)
modprobe netconsole netconsole=@/,@10.69.7.12/
# Write kernel messages netconsole
echo "8 4 1 7" > /proc/sys/kernel/printk
Setting up the receiver
socat UDP-recv:6666 -
Sending userspace message to dmesg
echo "Some Message" > /dev/kmsg