<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" 
   xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" 
   xmlns:html="http://www.w3.org/1999/html" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
   <title>The Geekess</title>
   <link>http://sarah.thesharps.us</link>
   <description>Linux, bicycling, open source, gardening, amateur rockets, and other seemingly unrelated hobbies.</description>
   <language>en</language>
   <copyright>Copyright 2008 Sarah Sharp, under Creative Commons Attribution Non-commercial Share Alike License</copyright>
   <ttl>60</ttl>
   <pubDate>Fri, 26 Mar 2010 16:41 GMT</pubDate>
   <managingEditor>sarah@thesharps.us</managingEditor>
   <generator>PyBlosxom http://pyblosxom.sourceforge.net/ 1.4.3 01/10/2008</generator>
<item>
   <title>Update for Netconsole Tutorial</title>
   <guid isPermaLink="false">2010-03-26-09-41</guid>
   <link>http://sarah.thesharps.us/2010-03-26-09-41.cherry</link>
   <description><![CDATA[
<p><a href="http://www.flickr.com/photos/pfly/130659908/"><img
src="http://lh6.ggpht.com/_KnE2M8e3X8Q/S6z4IPztwSI/AAAAAAAAE_Y/7O7nJuT8deQ/s200/130659908_922e26a071_b.jpg"
alt="Image Copyright pfly -- http://www.flickr.com/photos/pfly/130659908/"
align="left" /></a> A while back I posted a <a
href="http://sarah.thesharps.us/2009-02-22-09-00">Netconsole tutorial</a> 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.</p>

<p></p>

<p>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).</p>

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

<pre><code>#!/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
</code></pre>

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

<pre><code>#!/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
</code></pre>

<p>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:</p>

<pre><code>ping 10.0.0.2
</code></pre>

<p>On the source box, we run a similar command:</p>

<pre><code>ping 10.0.0.1
</code></pre>

<p>If the ping doesn't work, you have issues with either NetworkManager or the
wrong ethernet interface.</p>

<p>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:</p>

<pre><code>nc -u -l -p 6666 | tee logfile.txt
</code></pre>

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

<pre><code>#!/bin/sh
sudo dmesg -n 8
sudo modprobe netconsole netconsole=@/eth0,@10.0.0.1/
</code></pre>

<p>On the target box, you should see lines like this appear on standard out:</p>

<pre><code>[  632.180045] console [netcon0] enabled
[  632.180056] netconsole: network logging started
</code></pre>

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

]]></description>
   <category domain="http://sarah.thesharps.us"></category>
   <pubDate>Fri, 26 Mar 2010 16:41 GMT</pubDate>
</item>
</channel>
</rss>
