Archive for May, 2005

Grub Single Boot

Friday, May 27th, 2005

Grub allows you to boot into a new kernel only once. If you reboot the previous kernel will loaded. This is the safest way to do remote kernel updates.

Step 1: Once the new kernel is installed, determine which position the kernel has been installed too, example:
[root@rh9 root]# vi /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda2
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.28-1)
root (hd0,0)
kernel /vmlinuz-2.4.28-1 ro root=LABEL=/ hda=ide-scsi
initrd /initrd-2.4.28-1.img
title Red Hat Linux (2.4.20-37.9.legacy)
root (hd0,0)
kernel /vmlinuz-2.4.20-37.9.legacy ro root=LABEL=/ hda=ide-scsi
initrd /initrd-2.4.20-37.9.legacy.img

Replace default=0, with the number of the kernel you want the system to boot by default (starting with 0 for the first position). In this example, the kernel 2.4.20-37.9.legacy will be the default, in position 1, as its reliability is known.
change the line: default=0 to default=1
Save the file and exit.

Step 2: type grub

Step 3: At the grub prompt type the following:

savedefault --default=N --once

where N is the number of the kernel being tested, again, starting with 0 in our example, the new kernel is in position 0, so –default=0

Step 4: type quit

Step 5: Reboot the system, it will now boot into the new kernel. If for some reason the system does not work with the new kernel, or is otherwise non-responsive, powercycling the system will restore it to the known working kernel selected in Step 1.

If you are happy with the new kernel edit the /etc/grub.conf and set the system to boot into the new kernel permanently.