2005-04-16 »
On Being Obviously Smart
Adrian: if people tell you you're smart, try ordering them around and see if they'll do what they're told. Works for me.
Safe kernel crash dumps
So over the last few days, I've spent altogether too much time messing with kmsgdump, a tool that takes your 'dmesg' output and dumps it to a floppy or the parallel port. Although there are other similar projects, like LKCD and kdump (sorry, no link), they make me nervous, because: HELLO, MY KERNEL JUST CRASHED! STOP TRYING TO USE IT FOR STUFF! You'd think this would be obvious, but LKCD actually has the nerve to go and run your disk driver, spewing interrupts and DMAing data all over the place. Sure, it seems to work fine... but that's because all the crashes I'm having right now are simulated ones. What happens if it's my disk driver having the problem, or the interrupt handler is dead, or... anything? Answer: uh, well, there's no documentation that even discusses this possibility.
kmsgdump is better, because at least it's written by paranoid people. In fact, it's so paranoid that it reboots into real mode and uses the BIOS to write to a floppy. Well, that's pretty safe, but unfortunately most Nitix systems don't have a floppy disk. So what do we do? Adapt it to write to the hard disk, of course. Yes, I realize I'm a hypocrite. :)
I did this as carefully as possible: it reads each sector from the disk into memory first and checks that the sector's signature is exactly right before it writes it back, so it's extremely unlikely that you'll manage to write the wrong sector; and in the end, the only danger you have to worry about is writing the wrong sector. We generate the target file in advance from Linux, lilo style. And it actually works!
I'll be contributing the changes back to rddunlap in case he wants them, but he currently (rather rightly) thinks I'm crazy. Meanwhile, if you think you need something like this, let me know and I can send you the patch.
And once upon a time I used to think that Linux never crashed...
Why would you follow me on twitter? Use RSS.