Difference between revisions of "Systemd-boot"

From ArchWiki
Jump to: navigation, search
m (Added reference on automatic kernel image copying)
m (Adding boot entries: "an UEFI" -> "a UEFI")
(28 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 
[[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.
+
[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.
 
+
{{Note|
+
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).
+
}}
+
  
 
== Installing ==
 
== Installing ==
  
Install {{Pkg|gummiboot}} from [extra] and copy the bootloader 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.}}
  
If you are on a 64-bit UEFI system:
+
{{Note|If {{ic|gummiboot}} fails to create a boot entry, check whether all the conditions mentioned [[Unified_Extensible_Firmware_Interface#Requirements_for_UEFI_Variables_support_to_work_properly|here]] are met.}}
# cp /usr/lib/gummiboot/gummibootx64.efi $esp/EFI/gummiboot/gummiboot.efi
+
  
If you are on a 32-bit UEFI system:
+
Install {{Pkg|gummiboot}} and run the following to install gummiboot:
  
# cp /usr/lib/gummiboot/gummibootia32.efi $esp/EFI/gummiboot/gummiboot.efi
+
First, you should enable efivarfs and disable sysfs-efivars interface (for more info refer [[Unified_Extensible_Firmware_Interface#Inconsistency_between_efivarfs_and_sysfs-efivars|link]]):
  
Then add it to the boot configuration: (only needs to be done once; skip this when upgrading)
+
{{Note| The below commands should be run BEFORE '''chroot''', if any.}}
  
  # efibootmgr -c -d /dev/sd''X'' -p ''Y'' -w -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
+
  # umount /sys/firmware/efi/efivars
 +
# modprobe -r efivars
 +
# modprobe efivarfs
 +
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
  
where /dev/sd''X'' is the drive and ''Y'' is the partition number of your UEFISYS partition.
+
{{Note| The below commands should be run AFTER '''chroot''', if any.}}
  
{{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.}}
+
# gummiboot install
 +
 
 +
{{Note|The gummiboot command 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}}.}}
 +
 
 +
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.
  
 
== Configuring ==
 
== Configuring ==
  
The basic configuration is kept in {{ic|$esp/loader/loader.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}} – 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-*}}
Line 35: Line 37:
 
Example:
 
Example:
  
{{hc|$esp/loader/loader.conf|
+
{{hc|/boot/loader/loader.conf|
 
default  arch
 
default  arch
 
timeout  4
 
timeout  4
Line 43: Line 45:
  
 
== 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|
+
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 [[UEFI_Bootloaders#Sync_EFISTUB_Kernel]].
+
}}
+
 
+
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|title}} – operating system name. '''Required.'''
 
* {{ic|title}} – operating system name. '''Required.'''
Line 54: Line 51:
 
* {{ic|version}} – kernel version, shown only when multiple entries with same title exist. Optional.
 
* {{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+version 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; e.g. {{ic|/vmlinuz-linux}}. Either this or {{ic|linux}} (see below) is '''required.'''
+
* {{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|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|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.
Line 64: Line 61:
 
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
 
linux          /vmlinuz-linux
 
linux          /vmlinuz-linux
 
initrd        /initramfs-linux.img
 
initrd        /initramfs-linux.img
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
+
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw
 
}}
 
}}
  
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.
+
You can also add other EFI programs such as {{ic|\EFI\arch\grub.efi}}.  
  
{{hc|$esp/loader/entries/shell.conf|2=
+
{{Note|Gummiboot will automatically check for binaries of a Windows Installation ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}) or a UEFI Shell ({{ic|\shellx64.efi}}) and display entries for them, so you don't have to create these manually.}}
title          UEFI Shell
+
efi            \shellx64.efi
+
}}
+
  
== Automatic copy on update of gummiboot==
+
== Inside the boot menu ==
  
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]]):
+
=== Keys ===
  
{{hc|/etc/systemd/system/gummiboot_copy.path|<nowiki>
+
The following keys are used inside the menu:
[Unit]
+
* {{ic|Up/Down}} - select entry
Description=Copy new version of Gummiboot to UEFISYS Partition
+
* {{ic|Enter}} - boot the selected entry
 +
* {{ic|d}} - select the default entry to boot (stored in a non-volatile EFI variable)
 +
* {{ic|t/T}} - adjust the timeout (stored in a non-volatile EFI variable)
 +
* {{ic|e}} - edit the kernel command line
 +
* {{ic|q}} - quit
 +
* {{ic|v}} - show the gummiboot and UEFI version
 +
* {{ic|p}} - print the current configuration
 +
* {{ic|h}} - show key mapping
  
[Path]
+
These hotkeys will, when pressed inside the menu or during bootup, directly boot
PathChanged=/usr/lib/gummiboot/gummibootx64.efi
+
a specific entry:
Unit=gummiboot_copy.service
+
* {{ic|l}} - Linux
 +
* {{ic|w}} - Windows
 +
* {{ic|a}} - OS X
 +
* {{ic|s}} - EFI Shell
 +
* {{ic|1-9}} - number of entry
  
[Install]
+
== Troubleshooting ==
WantedBy=multi-user.target</nowiki>}}
+
  
{{hc|/etc/systemd/system/gummiboot_copy.service|<nowiki>
+
==== Manual entry using efibootmgr ====
[Unit]
+
Description=Copy new version of Gummiboot to UEFISYS Partition
+
  
[Service]
+
If {{ic|gummiboot install}} command failed you can create a EFI boot entry manually with {{ic|efibootmgr}} utility:
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 below commands should be run BEFORE '''chroot''', if any.}}
 
+
After creating the files run:
+
 
+
# systemctl enable gummiboot_copy.path
+
# systemctl start gummiboot_copy.path
+
 
+
== Separate boot and EFI partitions ==
+
 
+
TODO: link my kernel-post-upgrade stuff, https://github.com/grawity/code/tree/master/os/arch
+
 
+
== Inside the boot menu ==
+
  
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
+
# umount /sys/firmware/efi/efivars
 +
# modprobe -r efivars
  
==Troubleshooting==
+
  # modprobe efivars
====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.
+
{{Note| The below commands should be run AFTER '''chroot''', if any.}}
  
Though it has no additional info, here is my [https://bbs.archlinux.org/viewtopic.php?pid=1193147#p1193147 relevent forum thread].
+
# efibootmgr -c -w -d /dev/sdX -p Y -l '\EFI\gummiboot\gummibootx64.efi' -L "Gummiboot"

Revision as of 19:33, 5 September 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 whether all the conditions mentioned here are met.

Install gummiboot and run the following to install gummiboot:

First, you should enable efivarfs and disable sysfs-efivars interface (for more info refer link):

Note: The below commands should be run BEFORE chroot, if any.
# umount /sys/firmware/efi/efivars
# modprobe -r efivars
# modprobe efivarfs
# mount -t efivarfs efivarfs /sys/firmware/efi/efivars
Note: The below commands should be run AFTER chroot, if any.
# gummiboot install
Note: The gummiboot command 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 rw

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 a UEFI Shell (\shellx64.efi) and display entries for them, so you don't have to create these manually.

Inside the boot menu

Keys

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/T - adjust the timeout (stored in a non-volatile EFI variable)
  • e - edit the kernel command line
  • q - quit
  • v - show the gummiboot and UEFI version
  • p - print the current configuration
  • h - show key mapping

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

Manual entry using efibootmgr

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

Note: The below commands should be run BEFORE chroot, if any.
# umount /sys/firmware/efi/efivars
# modprobe -r efivars
# modprobe efivars
Note: The below commands should be run AFTER chroot, if any.
# efibootmgr -c -w -d /dev/sdX -p Y -l '\EFI\gummiboot\gummibootx64.efi' -L "Gummiboot"