Category: SysAdministration

16/09/08

Permalink 11:02:39 pm, by X-Drum Email , 270 words   English (GB)
Categories: Linux, SysAdministration

Remotely safe-upgrade a kernel

ok i know, many people would say "old!"
anyway here there is a quick recipe to remotely safe upgrade a kernel and reboot to (try to) use it:

The recipe:
First, build your new or updated kernel, and place the image in it's final destination (/boot/$kernel_new_ver/ in this recipe):

root@thunder linux # make && make modules_install
root@thunder linux # cp System.map /boot/$kernel_new_ver/
root@thunder linux # cp arch/$arch/boot/bzImage /boot/$kernel_new_ver/

Now, edit grub's configuration file and add or edit statements to get the following (note that commands in bold are critical for this feature to work):

[..snip..]
default saved
fallback 1
[..snip..]

# new kernel
title Gentoo ($kernel_new_ver)
kernel /boot/$kernel_new_ver/bzImage root=/dev/sda1 vga=0x314 panic=5
savedefault fallback
[..snip..]

# old_known_to_work kernel
title Gentoo ($kernel_old_ver)
kernel /boot/$kernel_old_ver/bzImage root=/dev/sda1 vga=0x314 panic=5
savedefault
[..snip..]

Finally issue the command:

root@thunder linux # grub-set-default 0

to tell which kernel grub should try to fire up at boot.

How it works:
At next system startup grub will try to boot $kernel_new_ver and will increase the set-default counter value (counter + 1), so in case of problems during the boot (eg: kernel panic due the lack of the main disk controller driver), the system will reboot automatically in 5 seconds thanks to the panic=5 statement.

Then at next boot the set-default counter value (now incremented by 1) will tell grub to boot the well known to work $kernel_old_ver, and voila' you are safe!

Search

February 2012
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

XML Feeds

powered by b2evolution