Difference between revisions of "Systemd-boot"

From ArchWiki
Jump to: navigation, search
m (Configuring - spelling)
m (Loader configuration: Use yes or no, instead of 0, 1 as seen in example upstream)
 
(344 intermediate revisions by 92 users not shown)
Line 1: Line 1:
 +
{{lowercase title}}
 
[[Category:Boot loaders]]
 
[[Category:Boot loaders]]
[http://freedesktop.org/wiki/Software/gummiboot Gummiboot] is a UEFI boot manager 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.
+
[[de:Gummiboot]]
 +
[[es:Systemd-boot]]
 +
[[ja:Systemd-boot]]
 +
[[ru:Systemd-boot]]
 +
[[zh-hans:Systemd-boot]]
 +
{{Related articles start}}
 +
{{Related|Arch boot process}}
 +
{{Related|Boot loaders}}
 +
{{Related|Secure Boot}}
 +
{{Related|Unified Extensible Firmware Interface}}
 +
{{Related articles end}}
  
{{Note|
+
'''systemd-boot''', previously called '''gummiboot''', is a simple UEFI boot manager which executes configured EFI images. The default entry is selected by a configured pattern (glob) or an on-screen menu. It is included with {{pkg|systemd}}, which is installed on Arch system by default.
In the following steps replace {{ic|$esp}} with path to your [[UEFI#Create_an_UEFI_System_Partition_in_Linux|EFI System Partition]], which is normally mounted on {{ic|/boot/efi}} (although some users have it on {{ic|/boot}} directly).
+
 
}}
+
It is simple to configure but it can only start EFI executables such as the Linux kernel [[EFISTUB]], UEFI Shell, GRUB, the Windows Boot Manager.
 +
 
 +
== Installation ==
 +
 
 +
=== Installing the EFI boot manager ===
 +
 
 +
To install the ''systemd-boot'' EFI boot manager, first make sure the system has booted in UEFI mode and that [[Unified Extensible Firmware Interface#UEFI variables|UEFI variables]] are accessible. This can be checked by running the command {{ic|efivar --list}}.
 +
 
 +
It should be noted that ''systemd-boot'' is only able to load the [[EFISTUB]] kernel from the [[EFI System Partition]] (ESP). To keep the kernel updated, it is simpler and therefore '''recommended''' to mount the ESP to {{ic|/boot}}.
 +
 
 +
If the ESP is '''not''' mounted to {{ic|/boot}}, the kernel and initramfs files must be copied onto that ESP. They will also need to be replaced regularly every time there is a kernel upgrade. The copy process can be automated by watching the kernel files for change using some systemd units as proposed in [[EFI System Partition#Using systemd]].
 +
 
 +
{{ic|''esp''}} will be used throughout this page to denote the ESP mountpoint, i.e. {{ic|/boot}}.
 +
 
 +
With the ESP mounted to {{ic|''esp''}}, use {{man|1|bootctl}} to install ''systemd-boot'' into the EFI system partition by running:
 +
# bootctl --path=''esp'' install
 +
This will copy the ''systemd-boot'' boot loader to the EFI partition: on a x64 architecture system the two identical binaries {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} and {{ic|''esp''/EFI/Boot/BOOTX64.EFI}} will be transferred to the ESP. It will then set ''systemd-boot'' as the default EFI application (default boot entry) loaded by the EFI Boot Manager.
 +
 
 +
Then, go to the [[#Configuration]] section to add boot loaders to make ''systemd-boot'' to function properly at boot time.
 +
 
 +
=== Updating the EFI boot manager ===
 +
 
 +
Whenever there is a new version of ''systemd-boot'', the boot manager must be updated by the user. This can be performed manually or the update can be automatically triggered using pacman hooks. The two approaches are described thereafter.
 +
 
 +
==== Manual update ====
 +
 
 +
''bootctl'' must be used to update ''systemd-boot''. If the {{ic|path}} parameter is not specified, {{ic|/efi}}, {{ic|/boot}}, and {{ic|/boot/efi}} are checked in turn.  
 +
 
 +
# bootctl update
 +
 
 +
If the ESP is mounted on a different location, the {{ic|path}} option can be passed as follows:
  
== Installing ==
+
# bootctl --path=''esp'' update
  
Install {{Pkg|gummiboot-efi}} from [extra] and copy the bootloader to the EFI partition:
+
{{Note|This is also the command to use when migrating from ''gummiboot'', before removing that package. If that package has already been removed, however, run {{ic|1=bootctl --path=''esp'' install}}.}}
  
If you are on a 64-bit UEFI system:
+
==== Automatic update ====
# cp /usr/lib/gummiboot/gummibootx64.efi $esp/EFI/gummiboot/gummiboot.efi
 
  
If you are on a 32-bit UEFI system:
+
The package {{AUR|systemd-boot-pacman-hook}} provides a [[Pacman hook]] to automate the update process. [[Install|Installing]] the package will add a hook which will be executed every time the {{Pkg|systemd}} package is upgraded.
 +
Alternatively, to replicate what the ''systemd-boot-pacman-hook'' package does without installing it, place the following pacman hook in the {{ic|/etc/pacman.d/hooks/}} directory:
  
# cp /usr/lib/gummiboot/gummibootia32.efi $esp/EFI/gummiboot/gummiboot.efi
+
{{hc|/etc/pacman.d/hooks/systemd-boot.hook|2=
 +
[Trigger]
 +
Type = Package
 +
Operation = Upgrade
 +
Target = systemd
  
Then add it to the boot configuration: (only needs to be done once; skip this when upgrading)
+
[Action]
 +
Description = Updating systemd-boot
 +
When = PostTransaction
 +
Exec = /usr/bin/bootctl update
 +
}}
  
# efibootmgr -c -d /dev/sd''X'' -p ''Y'' -w -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
+
== Configuration ==
  
where /dev/sd''X'' is the drive and ''Y'' is the partition number of your UEFISYS partition.
+
=== Loader configuration ===
  
{{note|{{ic|efibootmgr}} can be used 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.}}
+
The loader configuration is stored in the file {{ic|''esp''/loader/loader.conf}} and it is composed of the following options:
  
== Configuring ==
+
* {{ic|default}} – default entry to select as defined in [[#Adding loaders]]; it is given without the ''.conf'' suffix and it can be a wildcard like {{ic|arch-*}}.
 +
* {{ic|timeout}} – menu timeout in seconds before the default entry is booted. If this is not set, the menu will only be shown on {{ic|Space}} key (or most other keys actually work too) press during boot.
 +
* {{ic|editor}} – whether to enable the kernel parameters editor or not. {{ic|yes}} (default) is enabled, {{ic|no}} is disabled; since the user can add {{ic|1=init=/bin/bash}} to bypass root password and gain root access, it is strongly recommended to set this option to {{ic|no}}.
  
The basic configuration is kept in {{ic|$esp/loader/loader.conf}}, with just two possible configuration options:
+
Additional options are available starting with systemd '''v239''':
  
* {{ic|default}} – default entry to select (without the {{ic|.conf}} suffix); can be a wildcard like {{ic|arch-*}}
+
* {{ic|auto-entries}} – shows automatic entries for Windows, EFI Shell, and Default Loader if set to {{ic|1}} (default), {{ic|0}} to hide;
 +
* {{ic|auto-firmware}} – shows entry for rebooting into UEFI firmware settings if set to {{ic|1}} (default), {{ic|0}} to hide;
 +
* {{ic|console-mode}} – changes UEFI console mode: {{ic|0}} for 80x25, {{ic|1}} for 80x50, {{ic|2}} and above for non-standard modes provided by the device firmware, if any, {{ic|auto}} picks a suitable mode automatically, {{ic|max}} for highest available mode, {{ic|keep}} (default) for the firmware selected mode.
  
* {{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.
+
See [https://www.freedesktop.org/software/systemd/man/loader.conf.html loader.conf manual] for the full list of options.
  
 
Example:
 
Example:
  
{{hc|$esp/loader/loader.conf|
+
{{hc|''esp''/loader/loader.conf|
 
default  arch
 
default  arch
 
timeout  4
 
timeout  4
 +
editor  no
 +
}}
 +
 +
{{Tip|
 +
* {{ic|default}} and {{ic|timeout}} can be changed in the boot menu itself and changes will be stored as EFI variables, overriding these options.
 +
* A basic loader configuration file is located at {{ic|/usr/share/systemd/bootctl/loader.conf}}.}}
 +
 +
=== Adding loaders ===
 +
 +
''bootctl'' searches for boot menu items in {{ic|''esp''/loader/entries/*.conf}} – each file found must contain exactly one loader. The possible options are:
 +
 +
* {{ic|title}} – operating system name. '''Required.'''
 +
* {{ic|version}} – kernel version, shown only when multiple entries with same title exist. Optional.
 +
* {{ic|machine-id}} – machine identifier from {{ic|/etc/machine-id}}, shown only when multiple entries with same title and version exist. Optional.
 +
* {{ic|efi}} – EFI program to start, relative to your ESP ({{ic|''esp''}}); e.g. {{ic|/vmlinuz-linux}}. '''Either''' this parameter or {{ic|linux}} (see below) is '''required'''.
 +
* {{ic|options}} – command line options to pass to the EFI program or [[kernel parameters]]. Optional, but you will need at least {{ic|1=initrd=''efipath''}} and {{ic|1=root=''dev''}} if booting Linux.
 +
 +
For Linux boot, you can also use instead of {{ic|efi}} and {{ic|options}} the following syntax:
 +
* {{ic|linux}} and {{ic|initrd}} followed by the relative path of the corresponding files in the ESP;  e.g. {{ic|/vmlinuz-linux}}; this will be automatically translated into {{ic|efi ''path''}} and {{ic|1=options initrd=''path''}} – this syntax is only supported for convenience and has no differences in function.
 +
 +
An example of a loader file to launch Arch from a partition with the label ''arch_os'' and loading the Intel CPU [[microcode]]  is:
 +
{{hc|''esp''/loader/entries/arch.conf|2=
 +
title  Arch Linux
 +
linux  /vmlinuz-linux
 +
initrd  /intel-ucode.img
 +
initrd  /initramfs-linux.img
 +
options root=LABEL=''arch_os'' rw}}
 +
 +
''bootctl'' will automatically check at boot time for '''Windows Boot Manager''' at the location {{ic|/EFI/Microsoft/Boot/Bootmgfw.efi}}, '''EFI Shell''' {{ic|/shellx64.efi}} and '''EFI Default Loader''' {{ic|/EFI/BOOT/bootx64.efi}}, as well as specially prepared kernel files found in {{ic|/EFI/Linux}}. When detected, corresponding entries with titles {{ic|auto-windows}}, {{ic|auto-efi-shell}} and {{ic|auto-efi-default}}, respectively, will be generated. These entries do not require manual loader configuration. However, it does not auto-detect other EFI applications (unlike [[rEFInd]]), so for booting the Linux kernel, manual configuration entries must be created.
 +
 +
{{Note|
 +
* If you dual-boot Windows, it is strongly recommended to disable its default [[Dual boot with Windows#Fast_Start-Up|Fast Start-Up]] option.
 +
* Remember to load the Intel ''microcode'' with {{ic|initrd}} if applicable, an example is provided in [[Microcode#systemd-boot]].
 +
* The root partition can be identified with its {{ic|LABEL}} or its {{ic|PARTUUID}}. The latter can be found with the command {{ic|1=blkid -s PARTUUID -o value /dev/sd''xY''}}, where {{ic|''x''}} is the device letter and {{ic|''Y''}} is the partition number. This is required only to identify the root partition, not the {{ic|''esp''}}.
 
}}
 
}}
  
Note that both options can be changed in the boot menu itself, which will store them as EFI variables.
+
{{Tip|
 +
* The available boot entries which have been configured can be listed with the command {{ic|bootctl list}}.
 +
* An example entry file is located at {{ic|/usr/share/systemd/bootctl/arch.conf}}.
 +
* The [[kernel parameters]] for scenarios such as [[LVM]], [[LUKS]] or [[dm-crypt]] can be found on the relevant pages.
 +
}}
 +
==== EFI Shells or other EFI apps ====
  
== Adding boot entries ==
+
In case you installed EFI shells and other EFI application into the ESP, you can use the following snippets:
  
{{note|
+
{{hc|''esp''/loader/entries/uefi-shell-v1-x86_64.conf|2=
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.
+
title  UEFI Shell x86_64 v1
 +
efi   /EFI/shellx64_v1.efi
 
}}
 
}}
  
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:
+
{{hc|''esp''/loader/entries/uefi-shell-v2-x86_64.conf|2=
 +
title  UEFI Shell x86_64 v2
 +
efi    /EFI/shellx64_v2.efi
 +
}}
  
* {{ic|title}} – operating system name. '''Required.'''
+
{{Expansion|Add example on how to boot into EFI firmware setup.}}
 +
 
 +
=== Preparing kernels for /EFI/Linux ===
 +
 
 +
{{Style|Does not belong here, not specific to systemd-boot.}}
 +
 
 +
''/EFI/Linux'' is searched for specially prepared kernel files, which bundle the kernel, the init RAM disk (initrd), the kernel command line and {{ic|/etc/os-release}} into one single file. This file can be easily signed for secure boot.
 +
 
 +
{{Note|{{ic|systemd-boot}} requires that the {{ic|os-release}} file contain either {{ic|VERSION_ID}} or {{ic|BUILD_ID}} to generate an ID and automatically add the entry, which the Arch {{ic|os-release}} does not. Either maintain your own copy with one of them, or make your bundling script generate it automatically.}}
 +
 
 +
Put the kernel command line you want to use in a file, and create the bundle file like this:
 +
 
 +
{{hc|Kernel packaging command:|2=objcopy \
 +
    --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
 +
    --add-section .cmdline="kernel-command-line.txt" --change-section-vma .cmdline=0x30000 \
 +
    --add-section .linux="vmlinuz-file" --change-section-vma .linux=0x40000 \
 +
    --add-section .initrd="initrd-file" --change-section-vma .initrd=0x3000000 \
 +
    "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "''linux''.efi"}}
 +
 
 +
Optionally sign the {{ic|''linux''.efi}} file produced above.
 +
 
 +
Copy {{ic|''linux''.efi}} into {{ic|''esp''/EFI/Linux}}.
  
* {{ic|title-version}} – kernel version, shown only when multiple entries with same title exist. Optional.
+
=== Support hibernation ===
  
* {{ic|title-machine}} – machine identifier (usually first few letters from {{ic|/etc/machine-id}}, shown only when multiple entries with same title+version exist. Optional.
+
See [[Suspend and hibernate]].
  
* {{ic|efi}} – EFI program to start; e.g. {{ic|\EFI\arch\vmlinuz-linux.efi}}. '''Required.'''
+
=== Kernel parameters editor with password protection ===
  
* {{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.
+
Alternatively you can install {{AUR|systemd-boot-password}} which supports {{ic|password}} basic configuration option. Use {{ic|sbpctl generate}} to generate a value for this option.
  
An example entry for Arch Linux:
+
Install ''systemd-boot-password'' with the following command:
  
{{hc|$esp/loader/entries/arch.conf|2=
+
{{bc|1=# sbpctl install ''esp''}}
title          Arch Linux
 
linux          /vmlinuz-linux.efi
 
initrd        /initramfs-linux.img
 
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
 
}}
 
  
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.
+
With enabled editor you will be prompted for your password before you can edit kernel parameters.
  
You can also add other EFI programs such as {{ic|\EFI\arch\grub.efi}} or {{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}} (the Windows 7 boot manager). The EFI Shell, if installed, will be shown automatically.
+
== Keys inside the boot menu ==
  
{{hc|$esp/loader/entries/shell.conf|2=
+
The following keys are used inside the menu:
title          UEFI Shell
+
* {{ic|Up/Down}} - select entry
efi            /shellx64.efi
+
* {{ic|Enter}} - boot the selected entry
}}
+
* {{ic|d}} - select the default entry to boot (stored in a non-volatile EFI variable)
 +
* {{ic|-/T}} - decrease the timeout (stored in a non-volatile EFI variable)
 +
* {{ic|+/t}} - increase the timeout (stored in a non-volatile EFI variable)
 +
* {{ic|e}} - edit the kernel command line. It has no effect if the {{ic|editor}} config option is set to {{ic|0}}.
 +
* {{ic|v}} - show the gummiboot and UEFI version
 +
* {{ic|Q}} - quit
 +
* {{ic|P}} - print the current configuration
 +
* {{ic|h/?}} - help
  
== Automatic copy on update ==
+
These hotkeys will, when pressed inside the menu or during bootup, directly boot
 +
a specific entry:
  
The copying of the {{ic|/usr/lib/gummiboot/gummiboot*.efi}} to the EFI System partition can be automated with systemd (as can eg. be done for the [[UEFI_Bootloaders#Sync_EFISTUB_Kernel_in_UEFISYS_partition_using_Systemd|EFISTUB kernel]]):
+
* {{ic|l}} - Linux
 +
* {{ic|w}} - Windows
 +
* {{ic|a}} - OS X
 +
* {{ic|s}} - EFI Shell
 +
* {{ic|1-9}} - number of entry
  
{{hc|/etc/systemd/system/gummiboot_copy.path|<nowiki>
+
== Troubleshooting ==
[Unit]
 
Description=Copy new version of Gummiboot to UEFISYS Partition
 
  
[Path]
+
=== Installing after booting in BIOS mode ===
PathChanged=/usr/lib/gummiboot/gummibootx64.efi
 
Unit=gummiboot_copy.service
 
  
[Install]
+
{{Warning|This is not recommended.}}
WantedBy=multi-user.target</nowiki>}}
 
  
{{hc|/etc/systemd/system/gummiboot_copy.service|<nowiki>
+
If booted in BIOS mode, you can still install ''systemd-boot'', however this process requires you to tell firmware to launch ''systemd-boot'''s EFI file at boot, usually via two ways:
[Unit]
+
* you have a working EFI Shell somewhere else.
Description=Copy new version of Gummiboot to UEFISYS Partition
+
* your firmware interface provides a way of properly setting the EFI file that needs to be loaded at boot time.
  
[Service]
+
If you can do it, the installation is easier: go into your EFI Shell or your firmware configuration interface and change your machine's default EFI file to {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} ( or {{ic|systemd-bootia32.efi}} depending if your system firmware is 32 bit).
Type=oneshot
 
ExecStart=/bin/cp -f /usr/lib/gummiboot/gummibootx64.efi /boot/efi/EFI/gummiboot/gummiboot.efi
 
</nowiki>}}
 
  
Change {{ic|gummibootx64.efi}} to {{ic|gummibootia32.efi}} for a 32-bit UEFI system.
+
{{Note|The firmware interface of Dell Latitude series provides everything you need to setup EFI boot but the EFI Shell won't be able to write to the computer's ROM.}}
  
After creating the files run:
+
=== Manual entry using efibootmgr ===
  
# systemctl enable gummiboot_copy.path
+
If the {{ic|bootctl install}} command failed, you can create a EFI boot entry manually using {{Pkg|efibootmgr}}:
# systemctl start gummiboot_copy.path
 
  
== Separate boot and EFI partitions ==
+
# efibootmgr -c -d /dev/sdX -p Y -l "\EFI\systemd\systemd-bootx64.efi" -L "Linux Boot Manager"
  
TODO: link my kernel-post-upgrade stuff, https://github.com/grawity/code/tree/master/os/arch
+
where {{ic|/dev/sdXY}} is the [[EFI System Partition]].
  
== Inside the boot menu ==
+
{{Note|The path to the EFI image must use the backslash ({{ic|\}}) as the separator}}
  
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
+
=== Menu does not appear after Windows upgrade ===
  
==Troubleshooting==
+
See [[UEFI#Windows changes boot order]].
====Transferring to new HDD causes breakage====
 
Twice now I have transferred my installation from one disk to another, ESP included, and both times this broke my gummiboot setup.  With a lot of trial and error, I have discovered that gummiboot does not like configuration files that have been tranfserred from one disk to another (I used rsync).  
 
  
To solve this, delete the $ESP/loader directory and all of its contents, and recreate the necessary configuration files.
+
== See also ==
  
Though it has no additional info, here is my [https://bbs.archlinux.org/viewtopic.php?pid=1193147#p1193147 relevent forum thread].
+
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/
 +
* https://github.com/systemd/systemd/tree/master/src/boot/efi

Latest revision as of 09:41, 20 May 2018

systemd-boot, previously called gummiboot, is a simple UEFI boot manager which executes configured EFI images. The default entry is selected by a configured pattern (glob) or an on-screen menu. It is included with systemd, which is installed on Arch system by default.

It is simple to configure but it can only start EFI executables such as the Linux kernel EFISTUB, UEFI Shell, GRUB, the Windows Boot Manager.

Installation

Installing the EFI boot manager

To install the systemd-boot EFI boot manager, first make sure the system has booted in UEFI mode and that UEFI variables are accessible. This can be checked by running the command efivar --list.

It should be noted that systemd-boot is only able to load the EFISTUB kernel from the EFI System Partition (ESP). To keep the kernel updated, it is simpler and therefore recommended to mount the ESP to /boot.

If the ESP is not mounted to /boot, the kernel and initramfs files must be copied onto that ESP. They will also need to be replaced regularly every time there is a kernel upgrade. The copy process can be automated by watching the kernel files for change using some systemd units as proposed in EFI System Partition#Using systemd.

esp will be used throughout this page to denote the ESP mountpoint, i.e. /boot.

With the ESP mounted to esp, use bootctl(1) to install systemd-boot into the EFI system partition by running:

# bootctl --path=esp install

This will copy the systemd-boot boot loader to the EFI partition: on a x64 architecture system the two identical binaries esp/EFI/systemd/systemd-bootx64.efi and esp/EFI/Boot/BOOTX64.EFI will be transferred to the ESP. It will then set systemd-boot as the default EFI application (default boot entry) loaded by the EFI Boot Manager.

Then, go to the #Configuration section to add boot loaders to make systemd-boot to function properly at boot time.

Updating the EFI boot manager

Whenever there is a new version of systemd-boot, the boot manager must be updated by the user. This can be performed manually or the update can be automatically triggered using pacman hooks. The two approaches are described thereafter.

Manual update

bootctl must be used to update systemd-boot. If the path parameter is not specified, /efi, /boot, and /boot/efi are checked in turn.

# bootctl update

If the ESP is mounted on a different location, the path option can be passed as follows:

# bootctl --path=esp update
Note: This is also the command to use when migrating from gummiboot, before removing that package. If that package has already been removed, however, run bootctl --path=esp install.

Automatic update

The package systemd-boot-pacman-hookAUR provides a Pacman hook to automate the update process. Installing the package will add a hook which will be executed every time the systemd package is upgraded. Alternatively, to replicate what the systemd-boot-pacman-hook package does without installing it, place the following pacman hook in the /etc/pacman.d/hooks/ directory:

/etc/pacman.d/hooks/systemd-boot.hook
[Trigger]
Type = Package
Operation = Upgrade
Target = systemd

[Action]
Description = Updating systemd-boot
When = PostTransaction
Exec = /usr/bin/bootctl update

Configuration

Loader configuration

The loader configuration is stored in the file esp/loader/loader.conf and it is composed of the following options:

  • default – default entry to select as defined in #Adding loaders; it is given without the .conf suffix and it can be a wildcard like arch-*.
  • timeout – menu timeout in seconds before the default entry is booted. If this is not set, the menu will only be shown on Space key (or most other keys actually work too) press during boot.
  • editor – whether to enable the kernel parameters editor or not. yes (default) is enabled, no is disabled; since the user can add init=/bin/bash to bypass root password and gain root access, it is strongly recommended to set this option to no.

Additional options are available starting with systemd v239:

  • auto-entries – shows automatic entries for Windows, EFI Shell, and Default Loader if set to 1 (default), 0 to hide;
  • auto-firmware – shows entry for rebooting into UEFI firmware settings if set to 1 (default), 0 to hide;
  • console-mode – changes UEFI console mode: 0 for 80x25, 1 for 80x50, 2 and above for non-standard modes provided by the device firmware, if any, auto picks a suitable mode automatically, max for highest available mode, keep (default) for the firmware selected mode.

See loader.conf manual for the full list of options.

Example:

esp/loader/loader.conf
default  arch
timeout  4
editor   no
Tip:
  • default and timeout can be changed in the boot menu itself and changes will be stored as EFI variables, overriding these options.
  • A basic loader configuration file is located at /usr/share/systemd/bootctl/loader.conf.

Adding loaders

bootctl searches for boot menu items in esp/loader/entries/*.conf – each file found must contain exactly one loader. 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 (esp); e.g. /vmlinuz-linux. Either this parameter or linux (see below) is required.
  • options – command line options to pass to the EFI program or kernel parameters. Optional, but you will need at least initrd=efipath and root=dev if booting Linux.

For Linux boot, you can also use instead of efi and options the following syntax:

  • linux and initrd followed by the relative path of the corresponding files in the ESP; e.g. /vmlinuz-linux; this will be automatically translated into efi path and options initrd=path – this syntax is only supported for convenience and has no differences in function.

An example of a loader file to launch Arch from a partition with the label arch_os and loading the Intel CPU microcode is:

esp/loader/entries/arch.conf
title   Arch Linux
linux   /vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux.img
options root=LABEL=arch_os rw

bootctl will automatically check at boot time for Windows Boot Manager at the location /EFI/Microsoft/Boot/Bootmgfw.efi, EFI Shell /shellx64.efi and EFI Default Loader /EFI/BOOT/bootx64.efi, as well as specially prepared kernel files found in /EFI/Linux. When detected, corresponding entries with titles auto-windows, auto-efi-shell and auto-efi-default, respectively, will be generated. These entries do not require manual loader configuration. However, it does not auto-detect other EFI applications (unlike rEFInd), so for booting the Linux kernel, manual configuration entries must be created.

Note:
  • If you dual-boot Windows, it is strongly recommended to disable its default Fast Start-Up option.
  • Remember to load the Intel microcode with initrd if applicable, an example is provided in Microcode#systemd-boot.
  • The root partition can be identified with its LABEL or its PARTUUID. The latter can be found with the command blkid -s PARTUUID -o value /dev/sdxY, where x is the device letter and Y is the partition number. This is required only to identify the root partition, not the esp.
Tip:
  • The available boot entries which have been configured can be listed with the command bootctl list.
  • An example entry file is located at /usr/share/systemd/bootctl/arch.conf.
  • The kernel parameters for scenarios such as LVM, LUKS or dm-crypt can be found on the relevant pages.

EFI Shells or other EFI apps

In case you installed EFI shells and other EFI application into the ESP, you can use the following snippets:

esp/loader/entries/uefi-shell-v1-x86_64.conf
title  UEFI Shell x86_64 v1
efi    /EFI/shellx64_v1.efi
esp/loader/entries/uefi-shell-v2-x86_64.conf
title  UEFI Shell x86_64 v2
efi    /EFI/shellx64_v2.efi

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Add example on how to boot into EFI firmware setup. (Discuss in Talk:Systemd-boot#)

Preparing kernels for /EFI/Linux

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Does not belong here, not specific to systemd-boot. (Discuss in Talk:Systemd-boot#)

/EFI/Linux is searched for specially prepared kernel files, which bundle the kernel, the init RAM disk (initrd), the kernel command line and /etc/os-release into one single file. This file can be easily signed for secure boot.

Note: systemd-boot requires that the os-release file contain either VERSION_ID or BUILD_ID to generate an ID and automatically add the entry, which the Arch os-release does not. Either maintain your own copy with one of them, or make your bundling script generate it automatically.

Put the kernel command line you want to use in a file, and create the bundle file like this:

Kernel packaging command:
objcopy \
    --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \
    --add-section .cmdline="kernel-command-line.txt" --change-section-vma .cmdline=0x30000 \
    --add-section .linux="vmlinuz-file" --change-section-vma .linux=0x40000 \
    --add-section .initrd="initrd-file" --change-section-vma .initrd=0x3000000 \
    "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "linux.efi"

Optionally sign the linux.efi file produced above.

Copy linux.efi into esp/EFI/Linux.

Support hibernation

See Suspend and hibernate.

Kernel parameters editor with password protection

Alternatively you can install systemd-boot-passwordAUR which supports password basic configuration option. Use sbpctl generate to generate a value for this option.

Install systemd-boot-password with the following command:

# sbpctl install esp

With enabled editor you will be prompted for your password before you can edit kernel parameters.

Keys inside the boot menu

The following keys are used inside the menu:

  • Up/Down - select entry
  • Enter - boot the selected entry
  • d - select the default entry to boot (stored in a non-volatile EFI variable)
  • -/T - decrease the timeout (stored in a non-volatile EFI variable)
  • +/t - increase the timeout (stored in a non-volatile EFI variable)
  • e - edit the kernel command line. It has no effect if the editor config option is set to 0.
  • v - show the gummiboot and UEFI version
  • Q - quit
  • P - print the current configuration
  • h/? - help

These hotkeys will, when pressed inside the menu or during bootup, directly boot a specific entry:

  • l - Linux
  • w - Windows
  • a - OS X
  • s - EFI Shell
  • 1-9 - number of entry

Troubleshooting

Installing after booting in BIOS mode

Warning: This is not recommended.

If booted in BIOS mode, you can still install systemd-boot, however this process requires you to tell firmware to launch systemd-boot's EFI file at boot, usually via two ways:

  • you have a working EFI Shell somewhere else.
  • your firmware interface provides a way of properly setting the EFI file that needs to be loaded at boot time.

If you can do it, the installation is easier: go into your EFI Shell or your firmware configuration interface and change your machine's default EFI file to esp/EFI/systemd/systemd-bootx64.efi ( or systemd-bootia32.efi depending if your system firmware is 32 bit).

Note: The firmware interface of Dell Latitude series provides everything you need to setup EFI boot but the EFI Shell won't be able to write to the computer's ROM.

Manual entry using efibootmgr

If the bootctl install command failed, you can create a EFI boot entry manually using efibootmgr:

# efibootmgr -c -d /dev/sdX -p Y -l "\EFI\systemd\systemd-bootx64.efi" -L "Linux Boot Manager"

where /dev/sdXY is the EFI System Partition.

Note: The path to the EFI image must use the backslash (\) as the separator

Menu does not appear after Windows upgrade

See UEFI#Windows changes boot order.

See also