GRUB2 Quick Start

From Gentoo Wiki
Jump to: navigation, search

This article provides information on how to get up and running with GRUB2 in the simplest configurations. For more comprehensive information, see GRUB2.

Gentoo GRUB Legacy (0.97) to GRUB2 Migration Guide

The guide is available here.

GRUB slots

The sys-boot/grub package is slotted; both grub-0.97 and grub-2.00 may be installed at the same time.

If you want to install grub-0.97 or keep it installed after an upgrade, call emerge with the "0" slot on the end of the package atom. This will add sys-boot/grub:0 to your world file. For example:

root #emerge --noreplace sys-boot/grub:0

Only one version may be installed in your MBR at one time.

Installing the software

Set GRUB_PLATFORMS in make.conf (optional). If unset, grub will guess which platform you want. It guesses "pc" for x86/amd64.


# Standard PC (BIOS)

# UEFI on amd64

# UEFI and PC
GRUB_PLATFORMS="efi-64 pc"

Run emerge.

root #emerge --ask sys-boot/grub:2

Installing a bootable image

Mount your /boot volume if you have one.

root #mount /boot

If you are using an EFI platform, mount your EFI system volume at /boot/efi. This should be a FAT volume containing an EFI subdirectory.

root #mount /boot/efi

Run the grub2-install utility to copy the relevant files to /boot/grub. On the PC platform, this also installs a boot image to the master boot record (MBR) or a partition's boot sector.

grub2-install accepts a --target option to specify which CPU/Platform to install. If unspecified, grub2-install will make a guess; on amd64/x86 it will use "i386-pc" by default.

Installing to the MBR:

root #grub2-install /dev/sda
Installation finished. No error reported.

Installing to a partition (not recommended):

root #grub2-install /dev/sda1
Installation finished. No error reported.

Installing on EFI:

root #grub2-install --target=x86_64-efi
Installation finished. No error reported.

Automatic Configuration

GRUB2 is traditionally configured by using the grub2-mkconfig program to generate a config file.

grub2-mkconfig generates the config file based on template sections in /etc/grub.d. The default templates should cover most common boot setups.

user $ls /etc/grub.d
00_header 10_linux 20_linux_xen 30_os-prober 40_custom 41_custom README

The behavior of these templates may be controlled by setting variables in /etc/default/grub. See the GRUB manual for reference.

Kernel naming

In order for grub2-mkconfig to detect your Linux kernel(s), they must be named vmlinuz-version or kernel-version. For example:


If you use an initramfs, it should be named initramfs-version.img or initrd-version.img. File names generated by genkernel will also work.


Generate the grub.cfg file:

root #mount /boot
root #grub2-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...

Found linux image: /boot/vmlinuz-3.2.9


Silent Kernel Decompression

To silence kernel decompression make your line in /etc/default/grub look like this.




To boot systemd with GRUB2 make your line look like this



Loading another operating system

grub2-mkconfig can generate a configuration to load other operating systems. This requires the sys-boot/os-prober package.

To boot Windows, you should also install sys-fs/ntfs3g to allow grub2-mkconfig to probe NTFS filesystems.

Manual Configuration

Instead of using grub2-mkconfig, a typical simple grub.conf can easily be converted to be suitable for use in grub.cfg.

grub.conf (GRUB Legacy) grub.cfg (GRUB 2)
timeout 5

title Gentoo Linux 3.2.12
root (hd0,0)
kernel /boot/kernel-3.2.12-gentoo root=/dev/sda3


menuentry 'Gentoo Linux 3.2.12' {
linux /boot/kernel-3.2.12-gentoo root=/dev/sda3