Dobrica Pavlinušić's random unstructured stuff
grub: Revision 3
Examples of grub usage (as a reminder mostly)

{toc: }

^ install

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

.pre
install-mbr /dev/sda
grub-install /dev/sda
.pre

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

.pre
update-grub
.pre

^^ 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`

.pre
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
.pre

Here is simplier alternative:

.pre
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
.pre

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

.pre
grub-set-default 0
.pre

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