GRUB2 Quick Start

From Gentoo Wiki
Jump to: navigation, search

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

Contents

Gentoo GRUB Legacy (0.97) to GRUB2 Migration Guide

The guide is available at: http://www.gentoo.org/doc/en/grub2-migration.xml

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.

File/etc/portage/make.conf

# Standard PC (BIOS)
GRUB_PLATFORMS="pc"

# UEFI on amd64
GRUB_PLATFORMS="efi-64"

# 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/grub2. 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:

/boot/vmlinuz-3.4.3
/boot/kernel-2.6.39-gentoo

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

/boot/initramfs-3.4.3.img
/boot/initramfs-genkernel-x86_64-2.6.39-gentoo

Generate the grub.cfg file:

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

Found linux image: /boot/vmlinuz-3.2.9

done

SystemD

to boot systemd with grub2 make your line look like this

File/etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="init=/usr/bin/systemd"

loading windows 7

root # emerge os-prober ntfs3g

then run your grub2-mkconfig -o /boot/grub2/grub.cfg commands

if you just fixed your kernel to accept fuse then reboot to load your new kernel and rerun grub2-mkconfig

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

timeout=5


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

Personal tools
Namespaces

Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Navigation
Toolbox
Categories