Derwynd's Weblog

Derwynd's Weblog

Prevent kernel Panic on kernel compilation

This is how you can insure that after compiling a kernel on a remote system you can still have a running system without much bother about kernel panic

This is what the original grub.conf looks like

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-prep)
        root (hd0,0)
        kernel /vmlinuz-2.6.9-prep ro root=LABEL=/ 
        initrd /initrd-2.6.9-prep.img

Ok so now we have compiled a new kernel (for example 2.6.18-prep) and the grub looks like I’ve added the command of panic=5 (can have panic=* where * is the number of seconds it waits on a panic) at the end this is to reboot the computer in 5 seconds if kernel panics and will boot with default=1 kernel.

default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-prep)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-prep ro root=LABEL=/ panic=5
        initrd /initrd-2.6.18-prep.img

title CentOS (2.6.9-prep)
        root (hd0,0)
        kernel /vmlinuz-2.6.9-prep ro root=LABEL=/ panic=5
        initrd /initrd-2.6.9-prep.img

or run

perl -pi -e's/LABEL\=\//LABEL\=\/ panic\=5/g' /etc/grub.conf

But we need to test the default=0 kernel to do this before reboot type

echo "savedefault --default=0 --once" | grub --batch

And then reboot. It will boot once with new kernel. you can check it by uname -r

If the m/c successfully boots with the new kernel go ahead and change the grub to defaults to 0 and reboot once more.

Advertisements

November 10, 2008 - Posted by | Uncategorized

Sorry, the comment form is closed at this time.

%d bloggers like this: