Difference between revisions of "Systemd-boot"

From ArchWiki
Jump to: navigation, search
m (Adding boot entries)
m (There is no proof that rsync corrupts the gummiboot config files. I have successfully backed up and restores gummiboot config files across disks.)
(47 intermediate revisions by 14 users not shown)
Line 1: Line 1:
= Gummiboot =
+
[[Category:Boot loaders]]
 
+
[http://freedesktop.org/wiki/Software/gummiboot Gummiboot] is a UEFI boot loader written by Kay Sievers and Harald Hoyer. It is simple to configure, but can only start EFI executables, the Linux kernel (with CONFIG_EFI_STUB enabled), grub.efi, and such.
[http://freedesktop.org/wiki/Software/gummiboot Gummiboot] is a new UEFI bootloader written by Kay Sievers. It is simple to configure, but can boot only other EFI binaries, including Linux with CONFIG_EFI_STUB enabled.
+
 
+
{{Note|
+
In the following steps, replace {{ic|$esp}} with your EFI System Partition. Some users have it on {{ic|/boot/efi}}, others on {{ic|/boot}} directly.
+
}}
+
 
+
== Building ==
+
 
+
Download gummiboot source:
+
 
+
{{bc|
+
$ git clone git://anongit.freedesktop.org/gummiboot
+
$ cd gummiboot
+
}}
+
 
+
Compile:
+
 
+
{{bc|
+
$ make
+
}}
+
 
+
This should be quick, as there is only one file and no configuration options.
+
  
 
== Installing ==
 
== Installing ==
  
Copy Gummiboot to the EFI partition:
+
{{Note|{{ic|/usr/bin/gummiboot}} requires {{ic|efivarfs}} support in the kernel and requires it to be mounted at {{ic|/sys/firmware/efi/efivars}}. Mounting of efivarfs at this path is done automatically by systemd if the kernel supports efivarfs. LTS kernels do not support efivarfs. In such cases, the user needs to use {{ic|efibootmgr}} to create a boot entry for gummiboot.}}
  
{{bc|
+
{{Note|If {{ic|gummiboot}} fails to create a boot entry, check for existence of {{ic|/sys/firmware/efi/efivars/dump-*}} files. If they exist, delete them, reboot and retry {{ic|gummiboot}} again. If even this fails, retry {{ic|gummiboot}} after booting with {{ic|efi_no_storage_paranoia}} kernel parameter. If all these fail, try creating the boot entry using {{ic|efibootmgr}} or UEFI Shell v2 {{ic|bcfg}} command.}}
# install -Dm0644 gummiboot.efi $esp/EFI/gummiboot/gummiboot.efi
+
}}
+
  
Add it to the boot configuration: (only needs to be done once; skip this when upgrading)
+
Install {{Pkg|gummiboot}} from [extra] and run the following to install gummiboot:
 +
# gummiboot install
  
{{bc|
+
{{Note|gummiboot assumes that your EFI System Partition is mounted on {{ic|/boot}}. If your ESP is mounted on {{ic|/boot/efi}} you have to call the following gummiboot install command with the additional {{ic|--path}} switch. This also means that gummiboot will not be able to update itself automatically and you will have to call {{ic|1=gummiboot --path=/boot/efi update}} after every package update. Additionally you will have to make sure that the kernel and initramfs are copied onto the ESP as gummiboot can't load EFI binaries from other partitions. It is therefore strongly recommended to mount your ESP to {{ic|/boot}} if you use gummiboot. The rest of this article will assume that your ESP is mounted on {{ic|/boot}}.}}
# efibootmgr -c -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
+
}}
+
  
{{note|
+
This will automatically copy the gummiboot binary to your EFI System Partition and create a boot entry in the EFI Boot Manager. You should however still be able to boot gummiboot as it copies the binary to the default EFI binary location on your ESP ({{ic|/boot/EFI/BOOT/BOOTX64.EFI}} on x64 systems). Note that the installation process has to be done only once, updating will happen automatically by the post_install script of {{Pkg|gummiboot}} during package updates.
This can be done only when already booted in UEFI mode. If you do not have another UEFI bootloader set up, you can either run {{ic|gummiboot.efi}} from the UEFI Shell, or copy it to the "default" location {{ic|$esp/EFI/BOOT/BOOTX64.EFI}} for x86_64 systems.
+
}}
+
  
 
== Configuring ==
 
== Configuring ==
  
The basic configuration is kept in {{ic|$esp/loader/default.conf}}, with just two possible configuration options:
+
The basic configuration is kept in {{ic|/boot/loader/loader.conf}}, with just two possible configuration options:
  
* {{ic|default ''pattern''}} – default entry to select (without the {{ic|.conf}} suffix); can be a wildcard like {{ic|arch-*}}
+
* {{ic|default}} – default entry to select (without the {{ic|.conf}} suffix); can be a wildcard like {{ic|arch-*}}
  
* {{ic|timeout ''seconds''}} – menu timeout in seconds
+
* {{ic|timeout}} – menu timeout in seconds. If this is not set, the menu will only be shown when you hold the space key while booting.
  
 
Example:
 
Example:
  
{{hc|$esp/loader/default.conf|
+
{{hc|/boot/loader/loader.conf|
default arch
+
default arch
timeout 4
+
timeout 4
 
}}
 
}}
  
Line 60: Line 33:
  
 
== Adding boot entries ==
 
== Adding boot entries ==
 +
Gummiboot searches for boot menu items in {{ic|/boot/loader/entries/*.conf}} – each file found must contain exactly one boot entry. The possible options are:
  
{{note|
+
* {{ic|title}} – operating system name. '''Required.'''
If you have separate partitions for {{ic|/boot}} and {{ic|/boot/efi}}, you '''must''' copy the kernel and initramfs to the EFI partition. Gummiboot does not support loading kernels from other partitions than itself. See the section below on how to automate this.
+
}}
+
  
Gummiboot searches for boot menu items in {{ic|$esp/loader/entries/*.conf}} – each file found must contain exactly one boot entry. The possible options are:
+
* {{ic|version}} – kernel version, shown only when multiple entries with same title exist. Optional.
  
* {{ic|title ''title''}} – operating system name. Required.
+
* {{ic|machine-id}} – machine identifier from {{ic|/etc/machine-id}}, shown only when multiple entries with same title and version exist. Optional.
  
* {{ic|title-version ''version''}} – kernel version, shown only when multiple entries with same title exist. Optional.
+
* {{ic|efi}} – EFI program to start, relative to your ESP ({{ic|/boot}}); e.g. {{ic|/vmlinuz-linux}}. Either this or {{ic|linux}} (see below) is '''required.'''
  
* {{ic|title-machine ''id''}} – machine identifier (usually first few letters from {{ic|/etc/machine-id}}, shown only when multiple entries with same title+version exist. Optional.
+
* {{ic|options}} – Command-line options to pass to the EFI program. Optional, but you will need at least {{ic|1=initrd=''efipath''}} and {{ic|1=root=''dev''}} if booting Linux.
  
* {{ic|efi ''path''}} – EFI image to boot; e.g. {{ic|\EFI\arch\vmlinuz-linux.efi}}. Required.
+
For Linux, you can specify {{ic|linux ''path-to-vmlinuz''}} and {{ic|initrd ''path-to-initramfs''}}; this will be automatically translated to {{ic|efi ''path''}} and {{ic|1=options initrd=''path''}} – this syntax is only supported for convenience and has no differences in function.
 
+
* {{ic|options ''path''}} – Options to pass to the kernel or EFI image. For Linux, the initramfs is also configured here using {{ic|1=initrd=''path''}}. Required.
+
  
 
An example entry for Arch Linux:
 
An example entry for Arch Linux:
  
{{hc|$esp/loader/entries/arch.conf|2=
+
{{hc|/boot/loader/entries/arch.conf|2=
 
title          Arch Linux
 
title          Arch Linux
title-version  3.5-1
+
linux          /vmlinuz-linux
efi            \EFI\arch\vmlinuz-linux.efi
+
initrd         /initramfs-linux.img
options        initrd=\EFI\arch\initramfs-linux.img root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
+
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
 
}}
 
}}
  
When using {{ic|efi}}, the path to initrd is specified in {{ic|options}}.
+
You can also add other EFI programs such as {{ic|\EFI\arch\grub.efi}}.  
  
An alternate syntax is also supported, with {{ic|linux}} and {{ic|initrd}} keywords, but '''works exactly the same way''' otherwise:
+
{{Note|Gummiboot will automatically check for binaries of a Windows Installation ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}) or an UEFI Shell ({{ic|\shellx64.efi}}) and display entries for them, so you don't have to create these manually.}}
  
{{hc|$esp/loader/entries/arch-git.conf|2=
+
== Inside the boot menu ==
title          Arch Linux
+
linux          \EFI\arch\vmlinuz-linux-git.efi
+
initrd        \EFI\arch\initramfs-linux.img
+
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
+
}}
+
  
I have a {{ic|kernel-post-upgrade.sh}} script that automatically generates loader entries on kernel upgrade.
+
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
  
== Separate boot and EFI partitions ==
+
== Troubleshooting ==
  
TODO: link my kernel-post-upgrade stuff, https://github.com/grawity/code/tree/master/os/arch
+
==== Manual entry using efibootmgr ====
  
== Inside the boot menu ==
+
If {{ic|gummiboot install}} command failed you can create a EFI boot entry manually with {{ic|efibootmgr}} utility:
  
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
+
# efibootmgr -c -w -d /dev/sdX -p Y -l '\EFI\gummiboot\gummibootx64.efi' -L "Gummiboot"

Revision as of 19:25, 17 June 2013

Gummiboot is a UEFI boot loader written by Kay Sievers and Harald Hoyer. It is simple to configure, but can only start EFI executables, the Linux kernel (with CONFIG_EFI_STUB enabled), grub.efi, and such.

Installing

Note: /usr/bin/gummiboot requires efivarfs support in the kernel and requires it to be mounted at /sys/firmware/efi/efivars. Mounting of efivarfs at this path is done automatically by systemd if the kernel supports efivarfs. LTS kernels do not support efivarfs. In such cases, the user needs to use efibootmgr to create a boot entry for gummiboot.
Note: If gummiboot fails to create a boot entry, check for existence of /sys/firmware/efi/efivars/dump-* files. If they exist, delete them, reboot and retry gummiboot again. If even this fails, retry gummiboot after booting with efi_no_storage_paranoia kernel parameter. If all these fail, try creating the boot entry using efibootmgr or UEFI Shell v2 bcfg command.

Install gummiboot from [extra] and run the following to install gummiboot:

# gummiboot install
Note: gummiboot assumes that your EFI System Partition is mounted on /boot. If your ESP is mounted on /boot/efi you have to call the following gummiboot install command with the additional --path switch. This also means that gummiboot will not be able to update itself automatically and you will have to call gummiboot --path=/boot/efi update after every package update. Additionally you will have to make sure that the kernel and initramfs are copied onto the ESP as gummiboot can't load EFI binaries from other partitions. It is therefore strongly recommended to mount your ESP to /boot if you use gummiboot. The rest of this article will assume that your ESP is mounted on /boot.

This will automatically copy the gummiboot binary to your EFI System Partition and create a boot entry in the EFI Boot Manager. You should however still be able to boot gummiboot as it copies the binary to the default EFI binary location on your ESP (/boot/EFI/BOOT/BOOTX64.EFI on x64 systems). Note that the installation process has to be done only once, updating will happen automatically by the post_install script of gummiboot during package updates.

Configuring

The basic configuration is kept in /boot/loader/loader.conf, with just two possible configuration options:

  • default – default entry to select (without the .conf suffix); can be a wildcard like arch-*
  • timeout – menu timeout in seconds. If this is not set, the menu will only be shown when you hold the space key while booting.

Example:

/boot/loader/loader.conf
default  arch
timeout  4

Note that both options can be changed in the boot menu itself, which will store them as EFI variables.

Adding boot entries

Gummiboot searches for boot menu items in /boot/loader/entries/*.conf – each file found must contain exactly one boot entry. The possible options are:

  • title – operating system name. Required.
  • version – kernel version, shown only when multiple entries with same title exist. Optional.
  • machine-id – machine identifier from /etc/machine-id, shown only when multiple entries with same title and version exist. Optional.
  • efi – EFI program to start, relative to your ESP (/boot); e.g. /vmlinuz-linux. Either this or linux (see below) is required.
  • options – Command-line options to pass to the EFI program. Optional, but you will need at least initrd=efipath and root=dev if booting Linux.

For Linux, you can specify linux path-to-vmlinuz and initrd path-to-initramfs; this will be automatically translated to efi path and options initrd=path – this syntax is only supported for convenience and has no differences in function.

An example entry for Arch Linux:

/boot/loader/entries/arch.conf
title          Arch Linux
linux          /vmlinuz-linux
initrd         /initramfs-linux.img
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro

You can also add other EFI programs such as \EFI\arch\grub.efi.

Note: Gummiboot will automatically check for binaries of a Windows Installation (\EFI\Microsoft\Boot\Bootmgfw.efi) or an UEFI Shell (\shellx64.efi) and display entries for them, so you don't have to create these manually.

Inside the boot menu

TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot

Troubleshooting

Manual entry using efibootmgr

If gummiboot install command failed you can create a EFI boot entry manually with efibootmgr utility:

# efibootmgr -c -w -d /dev/sdX -p Y -l '\EFI\gummiboot\gummibootx64.efi' -L "Gummiboot"