Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Feb 2001 20:44:09 -0600 (CST)
From:      Mike Meyer <mwm@mired.org>
To:        Scott D <digitalox@earthlink.net>
Cc:        questions@freebsd.org
Subject:   Re: Is it possible to recover from kernel panics?
Message-ID:  <14980.43769.967098.878320@guru.mired.org>
In-Reply-To: <36239126@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Scott D <digitalox@earthlink.net> types:
> The other day when trying to write a new device driver, I caused a kernel 
> panic. I know I should learn more about how freebsd works first, but i am 
> plunging in headfirst here as I already have some programming skills.
> 
> I used my freebsd cd to boot into the emergency live file system, but could 
> not seem to mount /boot to copy the old kernel onto the broken one or 
> otherwise fix things.  I had the filesystem broken up into four or five 
> logical partitions on my ide drive, but all /dev of the emergency 
> filesystem would show was the four primaries. I mounted the primary it was 
> on but the entirety of the filesystem would not show up. I never could get 
> /boot to mount or find a solution, so I finally gave up and reinstalled.
> 
> Is there a way to be prepared or recover from this? I'm sure I'll be doing 
> this again soon...

Well, it depends on how badly you managed to screw up your disk, and
how far you're willing to go to recover your data. The normal panic
case is that you reboot, the system fsck's your disks, you check that
for anything vital that might have vanished to be restored, and you're
back. There are some things you can do to prepare for worse failures,
though.

For instance, when testing new kernels, *always* make sure you've got
a known good kernel to boot from on the disk. I.e. - rename a
completely staticly linked kernel to kernel.GOOD or some such.

Hmm - there used to be a page on disaster recovery in the handbook,
but I can't find it. Bleah. In summary, save the disk slice
information (from fdisk) and partition information (from disklabel). I
keep those in the cabinet with my offsite backups (you *do* have
backups, don't you?), and they've saved me more than once.  These will
allow you to recover a fragged mbr or disklabel using the fixit cdrom.

If you can arrange it, save the output from newfs for each partition,
but it's not worth a lot of effort - if the first two superblocks are
gone, you're probably SOL anyway. Read the fsck man page(s), and note
the comment about "Block 32 is usually an alternate superblock" (if it
isn't, break the the fingers of the person who installed the fs).

That's pretty much it for what you can reasonably do with hardware
that comes on a normal PC. The truly hardcore will talk about tweaking
file systems by futzing with the raw disk device in a debugger, but
that's not recommended unless you're writing file systems - and
probably not even then.

You should also to read the handbook chapter on kernel debugging.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14980.43769.967098.878320>