<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">The Geekess</title>
<subtitle type="html"><![CDATA[
Linux, bicycling, open source, gardening, amateur rockets, and other seemingly unrelated hobbies.
]]></subtitle>
<id>http://sarah.thesharps.us/2010-03-26-09-41.atom</id>
<link rel="alternate" type="text/html" href="http://sarah.thesharps.us" />
<link rel="self" type="application/atom+xml" href="http://sarah.thesharps.us/2010-03-26-09-41.atom" />


<author>
<name>Sarah Sharp</name>
<uri>http://sarah.thesharps.us/2010-03-26-09-41.atom</uri>
<email>sarah@thesharps.us</email>
</author>
<rights>Copyright 2008 Sarah Sharp, under Creative Commons Attribution Non-commercial Share Alike License</rights>
<generator uri="http://pyblosxom.sourceforge.net/" version="1.4.3 01/10/2008">
PyBlosxom http://pyblosxom.sourceforge.net/ 1.4.3 01/10/2008
</generator>

<updated>2010-03-26T16:41:00Z</updated>
<!-- icon?  logo?  -->

<entry>
<title type="html">Update for Netconsole Tutorial</title>
<category term="" />
<id>http://sarah.thesharps.us/2010/03/26/2010-03-26-09-41</id>
<updated>2010-03-26T16:41:00Z</updated>
<published>2010-03-26T16:41:00Z</published>
<link rel="alternate" type="text/html" href="http://sarah.thesharps.us/2010-03-26-09-41.cherry" />
<content type="html">&lt;p&gt;&lt;a href=&quot;http://www.flickr.com/photos/pfly/130659908/&quot;&gt;&lt;img
src=&quot;http://lh6.ggpht.com/_KnE2M8e3X8Q/S6z4IPztwSI/AAAAAAAAE_Y/7O7nJuT8deQ/s200/130659908_922e26a071_b.jpg&quot;
alt=&quot;Image Copyright pfly -- http://www.flickr.com/photos/pfly/130659908/&quot;
align=&quot;left&quot; /&gt;&lt;/a&gt; A while back I posted a &lt;a
href=&quot;http://sarah.thesharps.us/2009-02-22-09-00&quot;&gt;Netconsole tutorial&lt;/a&gt; for
how to capture Linux kernel debugging messages from a crashing machine.  I&apos;ve
refined the instructions down to three scripts and three commands, which are
after the break.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The scripts are meant to run on Ubuntu Gnome boxes, and they use specific paths
to kill NetworkManager.  If you&apos;re adapting these scripts for another distro or
KDE, you&apos;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).&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://minilop.net/~sarah/netconsole-target.sh&quot;&gt;first script&lt;/a&gt;,
netconsole-target.sh, is meant to be run on the box that is going to be
receiving the debugging messages:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/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
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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 &lt;a
href=&quot;http://minilop.net/~sarah/netconsole.sh&quot;&gt;second script&lt;/a&gt;, netconsole.sh:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/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
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ping 10.0.0.2
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On the source box, we run a similar command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ping 10.0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If the ping doesn&apos;t work, you have issues with either NetworkManager or the
wrong ethernet interface.&lt;/p&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;nc -u -l -p 6666 | tee logfile.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we run the &lt;a href=&quot;http://minilop.net/~sarah/netconsole-ending.sh&quot;&gt;third
script&lt;/a&gt;, netconsole-ending.sh, on the source machine to make it start
sending messages:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/sh
sudo dmesg -n 8
sudo modprobe netconsole netconsole=@/eth0,@10.0.0.1/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On the target box, you should see lines like this appear on standard out:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[  632.180045] console [netcon0] enabled
[  632.180056] netconsole: network logging started
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you can do whatever you want to crash your source machine and still be able
to get the log file out!  Happy hacking.&lt;/p&gt;
</content>
</entry>
</feed>

