Difference between revisions of "Systemd-boot"

From ArchWiki
Jump to: navigation, search
m (Configuring: default.conf -> loader.conf)
m (Configuring - spelling)
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
[[Category:Boot loaders]]
 
[[Category:Boot loaders]]
[http://freedesktop.org/wiki/Software/gummiboot Gummiboot] is a new UEFI bootloader written by Kay Sievers. It is simple to configure, but can only start EFI executables, such Linux (with CONFIG_EFI_STUB enabled), grub.efi, and such.
+
[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.
  
 
{{Note|
 
{{Note|
In the following steps replace {{ic|$esp}} with path to your EFI System Partition, which is normally mounted on {{ic|/boot/efi}} (although some users have it on {{ic|/boot}} directly).
+
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 {{AUR|gummiboot}} from AUR and copy the bootloader to the EFI partition:
+
Install {{Pkg|gummiboot-efi}} from [extra] and copy the bootloader to the EFI partition:
  
{{bc|
+
If you are on a 64-bit UEFI system:
# install -Dm0644 /usr/lib/gummiboot/gummiboot.efi $esp/EFI/gummiboot/gummiboot.efi
+
# cp /usr/lib/gummiboot/gummibootx64.efi $esp/EFI/gummiboot/gummiboot.efi
}}
+
 
 +
If you are on a 32-bit UEFI system:
 +
 
 +
# cp /usr/lib/gummiboot/gummibootia32.efi $esp/EFI/gummiboot/gummiboot.efi
  
 
Then add it to the boot configuration: (only needs to be done once; skip this when upgrading)
 
Then add it to the boot configuration: (only needs to be done once; skip this when upgrading)
  
{{bc|
+
# efibootmgr -c -d /dev/sd''X'' -p ''Y'' -w -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
# efibootmgr -c -L "Gummiboot" -l '\EFI\gummiboot\gummiboot.efi'
+
}}
+
  
{{note|
+
where /dev/sd''X'' is the drive and ''Y'' is the partition number of your UEFISYS partition.
{{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.
+
 
}}
+
{{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.}}
  
 
== Configuring ==
 
== Configuring ==
Line 30: Line 31:
 
* {{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-*}}
  
* {{ic|timeout}} – 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:
Line 63: Line 64:
 
{{hc|$esp/loader/entries/arch.conf|2=
 
{{hc|$esp/loader/entries/arch.conf|2=
 
title          Arch Linux
 
title          Arch Linux
title-version  3.5-1
+
linux          /vmlinuz-linux.efi
title-machine  067d8bfe
+
initrd         /initramfs-linux.img
efi            \EFI\arch\vmlinuz-linux.efi
+
options        root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
options        initrd=\EFI\arch\initramfs-linux.img root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 ro
+
 
}}
 
}}
  
Line 73: Line 73:
 
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}} or {{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}} (the Windows 7 boot manager). The EFI Shell, if installed, will be shown automatically.
  
{{hc|$esp/loader/entries/grub.conf|2=
+
{{hc|$esp/loader/entries/shell.conf|2=
title          GRUB
+
title          UEFI Shell
efi            \EFI\arch\grub.efi
+
efi            /shellx64.efi
 
}}
 
}}
 +
 +
== Automatic copy on update ==
 +
 +
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]]):
 +
 +
{{hc|/etc/systemd/system/gummiboot_copy.path|<nowiki>
 +
[Unit]
 +
Description=Copy new version of Gummiboot to UEFISYS Partition
 +
 +
[Path]
 +
PathChanged=/usr/lib/gummiboot/gummibootx64.efi
 +
Unit=gummiboot_copy.service
 +
 +
[Install]
 +
WantedBy=multi-user.target</nowiki>}}
 +
 +
{{hc|/etc/systemd/system/gummiboot_copy.service|<nowiki>
 +
[Unit]
 +
Description=Copy new version of Gummiboot to UEFISYS Partition
 +
 +
[Service]
 +
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.
 +
 +
After creating the files run:
 +
 +
# systemctl enable gummiboot_copy.path
 +
# systemctl start gummiboot_copy.path
  
 
== Separate boot and EFI partitions ==
 
== Separate boot and EFI partitions ==
Line 85: Line 116:
  
 
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
 
TODO: document keybindings from http://freedesktop.org/wiki/Software/gummiboot
 +
 +
==Troubleshooting==
 +
====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.
 +
 +
Though it has no additional info, here is my [https://bbs.archlinux.org/viewtopic.php?pid=1193147#p1193147 relevent forum thread].

Revision as of 05:04, 26 December 2012

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.

Note:

In the following steps replace $esp with path to your EFI System Partition, which is normally mounted on /boot/efi (although some users have it on /boot directly).

Installing

Install gummiboot-efi from [extra] and copy the bootloader to the EFI partition:

If you are on a 64-bit UEFI system:

# cp /usr/lib/gummiboot/gummibootx64.efi $esp/EFI/gummiboot/gummiboot.efi

If you are on a 32-bit UEFI system:

# cp /usr/lib/gummiboot/gummibootia32.efi $esp/EFI/gummiboot/gummiboot.efi

Then add it to the boot configuration: (only needs to be done once; skip this when upgrading)

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

where /dev/sdX is the drive and Y is the partition number of your UEFISYS partition.

Note: 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 gummiboot.efi from the UEFI Shell, or copy it to the "default" location $esp/EFI/boot/bootx64.efi for x86_64 systems.

Configuring

The basic configuration is kept in $esp/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:

$esp/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

Note:

If you have separate partitions for /boot and /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 $esp/loader/entries/*.conf – each file found must contain exactly one boot entry. The possible options are:

  • title – operating system name. Required.
  • title-version – kernel version, shown only when multiple entries with same title exist. Optional.
  • title-machine – machine identifier (usually first few letters from /etc/machine-id, shown only when multiple entries with same title+version exist. Optional.
  • efi – EFI program to start; e.g. \EFI\arch\vmlinuz-linux.efi. 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.

An example entry for Arch Linux:

$esp/loader/entries/arch.conf
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 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.

You can also add other EFI programs such as \EFI\arch\grub.efi or \EFI\Microsoft\Boot\Bootmgfw.efi (the Windows 7 boot manager). The EFI Shell, if installed, will be shown automatically.

$esp/loader/entries/shell.conf
title          UEFI Shell
efi            /shellx64.efi

Automatic copy on update

The copying of the /usr/lib/gummiboot/gummiboot*.efi to the EFI System partition can be automated with systemd (as can eg. be done for the EFISTUB kernel):

/etc/systemd/system/gummiboot_copy.path
[Unit]
Description=Copy new version of Gummiboot to UEFISYS Partition

[Path]
PathChanged=/usr/lib/gummiboot/gummibootx64.efi
Unit=gummiboot_copy.service

[Install]
WantedBy=multi-user.target
/etc/systemd/system/gummiboot_copy.service
[Unit]
Description=Copy new version of Gummiboot to UEFISYS Partition

[Service]
Type=oneshot
ExecStart=/bin/cp -f /usr/lib/gummiboot/gummibootx64.efi /boot/efi/EFI/gummiboot/gummiboot.efi

Change gummibootx64.efi to gummibootia32.efi for a 32-bit UEFI system.

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

Troubleshooting

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.

Though it has no additional info, here is my relevent forum thread.