systemd-boot

From Gentoo Wiki
(Redirected from Gummiboot)
Jump to: navigation, search

systemd-boot, formerly called gummiboot, is a simple UEFI boot manager capable of booting Linux and Windows in EFI mode.

Note
As of systemd 220, systemd-boot has been included with systemd (accessible via the bootctl command). If sys-apps/systemd has been installed on the system, then sys-boot/systemd-boot does not need to be installed.

Installation

The installation of systemd-boot consists of the following steps:

  1. Emerging the package (not necessary if sys-apps/systemd has been emerged).
  2. Preparing the EFI System Partition.
  3. Installing the systemd-boot UEFI boot manager.

Emerge

For the moment, systemd-boot is marked as unstable (~) so it must to be added to /etc/portage/package.accept_keywords:

root #mkdir -p /etc/portage/package.accept_keywords
root #echo "sys-boot/systemd-boot" >> /etc/portage/package.accept_keywords/systemd-boot

Next, install the sys-boot/systemd-boot package:

root #emerge --ask sys-boot/systemd-boot

EFI system partition

Make sure that an EFI System Partition (ESP) is available on the system. This is a GPT partition on the disk that is marked as EF00 (EFI System partition).

For instance, to create an ESP using sys-apps/gptfdisk:

root #gdisk /dev/sda
Command (? for help): n
Partition number (1-128, default 1): 1
First sector: (enter desired start sector and size, 100 MB should be plenty)
Command (? for help): t
Partition number (1-2): 1
Hex code or GUID (L to show codes, Enter = 8300): EF00
Command (? for help): w

The filesystem on this partition must be formatted as a FAT variant. FAT32 is recommended:

root #mkfs.vfat -F 32 /dev/sda1

Mount this location on the system (/boot/efi works just fine) and create the /boot/efi/EFI/boot location.

root #mkdir -p /boot/efi
root #mount /dev/sda1 /boot/efi

UEFI boot manager

The systemd-boot application makes the installation, which only needs to be performed once (unless a new version of systemd-boot needs to be installed), fairly simple. Verify the following:

  • The system is booted with EFI to start with (either from a EFI compatible media, or through any other UEFI boot manager) as it will otherwise fail to install.
  • The EFI variable file system (efivars) is mounted read/write:
root #mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Then perform the install itself:

root #bootctl --path /boot/efi install

The installation will install the proper EFI files so that the EFI-capable system will boot the systemd-boot bootloader.

Configuration

A boot loader entry needs to be created for each operating system.

Next to the boot loader entries, a small default configuration file can be created as well.

Default configuration entries

In /boot/efi/loader a file called loader.conf can be created which contains at most the following two entries:

A default entry
specifying which operating system entry to boot by default.
A timeout entry
specifying the number of seconds to wait before the default boot entry is loaded.

For instance, this would look like so:

FILE /boot/efi/loader/loader.confDefault settings
default gentoo
timeout 3

The name of the default entry is the name of the configuration entry file, as created in the next section, without the .conf suffix.

Operating system configuration entries

These entry files need to be located in the ESP, in the /boot/efi/loader/entries location. So if the EFI system partition is mounted at /boot/efi then this is at /boot/efi/loader/entries. The following is an example configuration entry named "gentoo":

FILE /boot/efi/loader/entries/gentoo.confGentoo configuration entry
title Gentoo Linux
linux /vmlinuz
options root=/dev/sda3

The linux entry points to an EFI stub Linux kernel file, installed in the ESP.

Although the EFI stub kernel configuration works fine, it has the downside that

  • New Linux kernels are somewhat risky to test out because only a single kernel is booted.
  • Adding boot options requires rebuilding the Linux kernel.

With systemd-boot, additional entries can be configured for new Linux kernel tests, and additional boot options are easy to add to the configuration entry file, or even at boot time.

One-time boot loader options

In order to boot the system with a particular boot option, in the systemd-boot screen, press e to edit the options.

The changes made in the systemd-boot screen are not preserved!

See also

  • systemd — a modern SysV-style init and rc replacement for Linux systems.

External resources