[ Home | RSS 2.0 | ATOM 1.0 ]
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:
On the source box, we run a similar command:
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.
Powered by PyBlosxom