A while back I posted a Netconsole tutorial for
how to capture Linux kernel debugging messages from a crashing machine. I've
refined the instructions down to three scripts and three commands, which are
after the break.
The scripts are meant to run on Ubuntu Gnome boxes, and they use specific paths to kill NetworkManager. If you're adapting these scripts for another distro or KDE, you're going to have to change them a bit. You will also have to modify the scripts to have the correct ethernet interface (e.g. eth0).
The first script, netconsole-target.sh, is meant to be run on the box that is going to be receiving the debugging messages:
#!/bin/sh
sudo killall nm-applet
sudo /etc/init.d/NetworkManager stop
sudo /etc/init.d/networking stop
sudo ip addr add 10.0.0.1/8 dev eth0
sudo ip link set eth0 up
This sets up the target box to have an IP address of 10.0.0.1. Now we set up the source box to have an IP address of 10.0.0.2 with the second script, netconsole.sh:
#!/bin/sh
sudo /etc/init.d/NetworkManager stop
sudo /etc/init.d/networking stop
sudo killall nm-applet
sudo ip link set eth0 up
sudo ip addr add 10.0.0.2/8 dev eth0
/sbin/ifconfig eth0
Now, we connect the crossover cable (or straight-through cable if one of the boxes can auto-negociate, like Thinkpads can). On the target box, we make sure we can ping the source box:
ping 10.0.0.2
On the source box, we run a similar command:
ping 10.0.0.1
If the ping doesn't work, you have issues with either NetworkManager or the wrong ethernet interface.
Once we have both boxes configured, we set up the target box to receive the messages and pipe them to standard out and a log file, like so:
nc -u -l -p 6666 | tee logfile.txt
Now we run the third script, netconsole-ending.sh, on the source machine to make it start sending messages:
#!/bin/sh
sudo dmesg -n 8
sudo modprobe netconsole netconsole=@/eth0,@10.0.0.1/
On the target box, you should see lines like this appear on standard out:
[ 632.180045] console [netcon0] enabled
[ 632.180056] netconsole: network logging started
Now you can do whatever you want to crash your source machine and still be able to get the log file out! Happy hacking.
| link | 3 comment(s)
Posted by Brandon Philips at Fri Mar 26 11:44:15 2010
You can configure a static NetworkManager connection.
1) Right click on network manager tray icon -> Connection Information
2) Add Wired and name it static or something.
3) IPv4 Settings and set your netmask and ip.
Now you can use network manager to quickly switch from dhcp to static.
Or you can buy a USB network adapter to use for your laptop. I find it is easier than constantly switching from Internet to netconsole mode.
Cheers!
Posted by Brandon Philips at Fri Mar 26 11:54:00 2010
One more thing. There is a nice little script that we have in SUSE that can help too:
http://ifup.org/~philips/netconsole-server
The package is netconsole-tools on SUSE IIRC.
Posted by x-alina at Sat Mar 27 10:21:45 2010
Why does this kernel module not support IPv6? The autoconfigured link-local address would be perfect for this purpose, without configuring the NetworkManager.

