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.


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

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

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

# Forever=-1, Now=0

# Numbering starts at 1 (IS THIS TRUE?)

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

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

menuentry "Linux with RAID1" {
    search --set=root --label OS1 --hint hd0,msdos8
    linux /boot/vmlinuz root=/dev/sda2
    initrd /boot/initramfs

menuentry "Xen" {
    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.


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@,6666@
    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@,6666@
    initrd /boot/initramfs

menuentry 'Normal Kernel: vmlinux.old' {
    set root=(md/ssdset)
    linux /boot/vmlinuz-3.11.6.old root=/dev/md0 netconsole=4444@,6666@
    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]).


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.

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

Installing can be a real PITA. Sysresc can use grub-install. Figuring out how to deploy it is not obvious. But this has worked.

grub-install --root-directory=/mnt/ /dev/sda

At the least it installed some stage1 stuff in the MBR. This can be explicitly checked with something like this.

% dd if=/dev/sda count=1 bs=512 | xxd | grep -B1 RUB
1+0 records in
1+0 records out
512 bytes (512 B) copied, 5.0763e-05 s, 10.1 MB/s
0000170: 06be 947d e830 00be 997d e82a 00eb fe47  ...}.0...}.*...G
0000180: 5255 4220 0047 656f 6d00 4861 7264 2044  RUB .Geom.Hard D

You can blank that out and if grub installation puts it back, you can be pretty sure it’s ok. (Obviously save a copy of the MBR in case you overwrite something important.)

It may be necessary to run just grub or grub --no-floppy for old-school cases. Then you need this kind of thing.

grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83

grub> find /boot/grub/stage1

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists... yes
 Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  18 sectors are embedded.
 Running "install /boot/grub/stage1 (hd0) (hd0)1+18 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"
... succeeded

grub> quit