grub


Examples of grub usage (as a reminder mostly)



install

Sometimes, grub-install won't owerwrite MBR. If that happends, first reinstall MBR and then grub:

install-mbr /dev/sda
grub-install /dev/sda

If you forget to make /boot/grub/menu.lst (as I did), you will have to do a lot of typing in grub console, so be sure to also run

update-grub

LVM gotchas

There is also corner-case when you have lvm compiled into kernel and /boot partition on LVM. grub will be confused, and simplest solution that I found so far is to move /boot to partition. If you don't have any free space handy, you might try to move swap to LVM and /boot onto swap partition.

fallback

After you have installed grub, you might want to configure fallback kernels. First configure different kernels, with fail-safe one as last one:

/boot/grub/menu.lst

default         saved

fallback        1 2

title           OpenVZ 2.6.18-028test010
root            (hd0,2)
kernel          /vmlinuz-2.6.18-028test018 root=/dev/mapper/vg-root ro
initrd          /initrd.img-2.6.18-028test018
savedefault     fallback
boot

title           Debian GNU/Linux, kernel 2.6.18-028test007.2-ovz-enterprise
root            (hd0,2)
kernel          /vmlinuz-2.6.18-028test007.2-ovz-enterprise root=/dev/mapper/vg-root ro
initrd          /initrd.img-2.6.18-028test007.2-ovz-enterprise
savedefault     fallback
boot

title           Debian GNU/Linux, kernel 2.6.18-3-686
root            (hd0,2)
kernel          /vmlinuz-2.6.18-3-686 root=/dev/mapper/vg-root ro
initrd          /initrd.img-2.6.18-3-686
savedefault
boot

Here is simplier alternative:

default         0

fallback        1

title Debian GNU/Linux
root (hd0,0)
kernel /boot/vmlinuz root=/dev/md0 reboot=warm

title Debian GNU/Linux, with the old kernel
root (hd0,0)
kernel /boot/vmlinuz.old root=/dev/md0 reboot=warm

Then setup reset to default kernel (0) upon successful boot. On debian, you can just add following line in /etc/rc.local:

grub-set-default 0

You might also want to run this once by hand, so that first boot is in first kernel (most recent one presumably).