UEFI

UEFI seems like a conceptually good thing since BIOS behavior is based on conventions from the early 80s. But it is a bit of a radical change for some of us. This is an excellent introduction to the topic of UEFI.

GRUB2

The program grub-mkconfig generates grub.cfg files suitable for most cases. It is suitable for use when upgrading a distribution, and will discover available kernels and attempt to generate menu entries for them.

grub-mkconfig does have some limitations. While adding extra custom menu entries to the end of the list can be done by editing /etc/grub.d/40_custom or creating /boot/grub/custom.cfg, changing the order of menu entries or changing their titles may require making complex changes to shell scripts stored in /etc/grub.d/. This may be improved in the future. In the meantime, those who feel that it would be easier to write grub.cfg directly are encouraged to do so, and to disable any system provided by their distribution to automatically run grub-mkconfig.

  • /etc/default/grub - Controls grub2-mkconfig.

  • grub2-mkconfig -o /boot/grub/grub.cfg - Makes /boot/grub/grub.cfg

  • grub2-install - Uses /boot/grub/grub.cfg

Note
Grub2 uses /boot/grub/grub.*cfg* and not grub.conf like legacy Grub did. If this is not done correctly, you’ll get a Grub prompt on boot but no menu.
Example of most simple /boot/grub/grub.cfg
timeout=5
default=0
fallback=1

menuentry 'Xed Gentoo' {
    linux (hd0,msdos1)/boot/vmlinuz root=/dev/sda1
}

menuentry 'Xed Gentoo (revert to previous kernel)' {
    linux (hd0,msdos1)/boot/vmlinuz.old root=/dev/sda1
}
Example /boot/grub/grub.cfg
# Foreground/background
color_normal=green/black
color_highlight=red/black
menu_color_normal=black/green
menu_color_highlight=black/red

# Forever=-1, Now=0
timeout=10

# Numbering starts at 1 (IS THIS TRUE?)
default=1

# If Grub can not boot the default, this boots.
fallback=2

menuentry "Normal Linux" {
   search --set=root --label OS1 --hint hd0,msdos8
   linux /boot/vmlinuz root=/dev/sda2
}

# THIS NEEDS TO BE FIXED UNTIL IT IS KNOWN TO WORK.
menuentry "Linux with RAID1" {
    search --set=root --label OS1 --hint hd0,msdos8
    linux /boot/vmlinuz root=/dev/sda2
    initrd /boot/initramfs
}

menuentry "Xen" {
    root=hd0,2
    multiboot /boot/xen.gz dom0_mem=2048M
    module /boot/vmlinuz root=/dev/sda2
}

Not in chroot (This didn’t work and needs to be refined.):

grub2-install --boot-directory=/mnt/gentoo/boot --grub-setup=/mnt/gentoo/boot/grub/grub.cfg /dev/sda

Hmm… Then I tried just this and it did install ok..

grub2-install /dev/sda
grub2-install /dev/sdb

Here’s my Grub2 entry. Note that for Xen, the initramfs is also module and not initrd as you might expect.

timeout=5
default=0

menuentry 'Xen Hypervisor' {
    set root=(md/ssdset)
    multiboot /boot/xen.gz dom0_mem=2048M
    module /boot/vmlinuz udbg-immortal root=/dev/md0
    # NOT initrd !
    module /boot/initramfs
}

menuentry 'Xen Hypervisor - netconsole' {
    set root=(md/ssdset)
    multiboot /boot/xen.gz dom0_mem=2048M
    module /boot/vmlinuz udbg-immortal root=/dev/md0 netconsole=4444@192.168.30.208/eth0,6666@192.168.30.8/50:46:5d:a5:18:87
    module /boot/initramfs
}

menuentry 'Normal Kernel: vmlinux' {
    set root=(md/ssdset)
    linux /boot/vmlinuz-3.14.5 root=/dev/md0
    initrd /boot/initramfs
}

menuentry 'Normal Kernel: vmlinux netconsole' {
    set root=(md/ssdset)
    linux /boot/vmlinuz-3.14.5 root=/dev/md0 netconsole=4444@192.168.30.208/eth0,6666@192.168.30.8/50:46:5d:a5:18:87
    initrd /boot/initramfs
}

menuentry 'Normal Kernel: vmlinux.old' {
    set root=(md/ssdset)
    linux /boot/vmlinuz-3.11.6.old root=/dev/md0 netconsole=4444@192.168.30.208/eth0,6666@192.168.30.8/50:46:5d:a5:18:87
    initrd /boot/initramfs
}

Modules are searched for in /boot/grub/i386-pc/*.mod but it seems that RAID1 is already included in core GRUB2 (unlike RAID[56]).

Windows

Can GRUB boot Windows? In theory. Here are some things to try.

set root=(hd0,msdos1)
insmod part_msdos
insmod ntfs
ntldr (hd0,msdos1)/bootmgr

Note that all or none of this may be important. Also this might be relevant syntax.

chainloader +1

Legacy GRUB

Probably best to move on to GRUB2. Here’s a small simple example of an ordinary old-fashioned configuration file. Note that it is .conf and not .cfg.

/boot/grub/grub.conf
default 0
timeout 8

title=Gentoo Linux
root (hd0,0)
kernel (hd0,0)/vmlinuz

title=Gentoo Linux (previous)
root (hd0,0)
kernel (hd0,0)/vmlinuz.old

title=EXPERIMENTAL Gentoo Linux
root (hd0,1)
# genkernel users:
kernel (hd0,1)/kernel-experimental boot_delay=200 udbg-immortal