]> git.ipfire.org Git - thirdparty/systemd.git/blob - docs/_booting/BOOT_LOADER_INTERFACE.md
docs: use collections to structure the data
[thirdparty/systemd.git] / docs / _booting / BOOT_LOADER_INTERFACE.md
1 ---
2 title: Boot Loader Interface
3 category: Booting
4 layout: default
5 SPDX-License-Identifier: LGPL-2.1-or-later
6 ---
7
8 # The Boot Loader Interface
9
10 systemd can interface with the boot loader to receive performance data and
11 other information, and pass control information. This is only supported on EFI
12 systems. Data is transferred between the boot loader and systemd in EFI
13 variables. All EFI variables use the vendor UUID
14 `4a67b082-0a4c-41cf-b6c7-440b29bb8c4f`.
15
16 * The EFI Variable `LoaderTimeInitUSec` contains the timestamp in microseconds
17 when the loader was initialized. This value is the time spent in the firmware
18 for initialization, it is formatted as numeric, NUL-terminated, decimal
19 string, in UTF-16.
20
21 * The EFI Variable `LoaderTimeExecUSec` contains the timestamp in microseconds
22 when the loader finished its work and is about to execute the kernel. The
23 time spent in the loader is the difference between `LoaderTimeExecUSec` and
24 `LoaderTimeInitUSec`. This value is formatted the same way as
25 `LoaderTimeInitUSec`.
26
27 * The EFI variable `LoaderDevicePartUUID` contains the partition GUID of the
28 ESP the boot loader was run from formatted as NUL-terminated UTF16 string, in
29 normal GUID syntax.
30
31 * The EFI variable `LoaderConfigTimeout` contains the boot menu timeout
32 currently in use. It may be modified both by the boot loader and by the
33 host. The value should be formatted as numeric, NUL-terminated, decimal
34 string, in UTF-16. The time is specified in seconds. In addition some
35 non-numeric string values are also accepted. A value of `menu-force`
36 will disable the timeout and show the menu indefinitely. If set to `0` or
37 `menu-hidden` the default entry is booted immediately without showing a menu.
38 Unless a value of `menu-disabled` is set, the boot loader should provide a
39 way to interrupt this by for example listening for key presses for a brief
40 moment before booting.
41
42 * Similarly, the EFI variable `LoaderConfigTimeoutOneShot` contains a boot menu
43 timeout for a single following boot. It is set by the OS in order to request
44 display of the boot menu on the following boot. When set overrides
45 `LoaderConfigTimeout`. It is removed automatically after being read by the
46 boot loader, to ensure it only takes effect a single time. This value is
47 formatted the same way as `LoaderConfigTimeout`. If set to `0` the boot menu
48 timeout is turned off, and the menu is shown indefinitely.
49
50 * The EFI variable `LoaderEntries` may contain a series of boot loader entry
51 identifiers, one after the other, each individually NUL terminated. This may
52 be used to let the OS know which boot menu entries were discovered by the
53 boot loader. A boot loader entry identifier should be a short, non-empty
54 alphanumeric string (possibly containing `-`, too). The list should be in the
55 order the entries are shown on screen during boot. See below regarding a
56 recommended vocabulary for boot loader entry identifiers.
57
58 * The EFI variable `LoaderEntryDefault` contains the default boot loader entry
59 to use. It contains a NUL-terminated boot loader entry identifier.
60
61 * Similarly, the EFI variable `LoaderEntryOneShot` contains the default boot
62 loader entry to use for a single following boot. It is set by the OS in order
63 to request booting into a specific menu entry on the following boot. When set
64 overrides `LoaderEntryDefault`. It is removed automatically after being read
65 by the boot loader, to ensure it only takes effect a single time. This value
66 is formatted the same way as `LoaderEntryDefault`.
67
68 * The EFI variable `LoaderEntrySelected` contains the boot loader entry
69 identifier that was booted. It is set by the boot loader and read by
70 the OS in order to identify which entry has been used for the current boot.
71
72 * The EFI variable `LoaderFeatures` contains a 64-bit unsigned integer with a
73 number of flags bits that are set by the boot loader and passed to the OS and
74 indicate the features the boot loader supports. Specifically, the following
75 bits are defined:
76
77 * `1 << 0` → The boot loader honours `LoaderConfigTimeout` when set.
78 * `1 << 1` → The boot loader honours `LoaderConfigTimeoutOneShot` when set.
79 * `1 << 2` → The boot loader honours `LoaderEntryDefault` when set.
80 * `1 << 3` → The boot loader honours `LoaderEntryOneShot` when set.
81 * `1 << 4` → The boot loader supports boot counting as described in [Automatic Boot Assessment](AUTOMATIC_BOOT_ASSESSMENT).
82 * `1 << 5` → The boot loader supports looking for boot menu entries in the Extended Boot Loader Partition.
83 * `1 << 6` → The boot loader supports passing a random seed to the OS.
84 * `1 << 13` → The boot loader honours `menu-disabled` option when set.
85
86 * The EFI variable `LoaderSystemToken` contains binary random data,
87 persistently set by the OS installer. Boot loaders that support passing
88 random seeds to the OS should use this data and combine it with the random
89 seed file read from the ESP. By combining this random data with the random
90 seed read off the disk before generating a seed to pass to the OS and a new
91 seed to store in the ESP the boot loader can protect itself from situations
92 where "golden" OS images that include a random seed are replicated and used
93 on multiple systems. Since the EFI variable storage is usually independent
94 (i.e. in physical NVRAM) of the ESP file system storage, and only the latter
95 is part of "golden" OS images, this ensures that different systems still come
96 up with different random seeds. Note that the `LoaderSystemToken` is
97 generally only written once, by the OS installer, and is usually not touched
98 after that.
99
100 If `LoaderTimeInitUSec` and `LoaderTimeExecUSec` are set, `systemd-analyze`
101 will include them in its boot-time analysis. If `LoaderDevicePartUUID` is set,
102 systemd will mount the ESP that was used for the boot to `/boot`, but only if
103 that directory is empty, and only if no other file systems are mounted
104 there. The `systemctl reboot --boot-loader-entry=…` and `systemctl reboot
105 --boot-loader-menu=…` commands rely on the `LoaderFeatures` ,
106 `LoaderConfigTimeoutOneShot`, `LoaderEntries`, `LoaderEntryOneShot`
107 variables.
108
109 ## Boot Loader Entry Identifiers
110
111 While boot loader entries may be named relatively freely, it's highly
112 recommended to follow the following rules when picking identifiers for the
113 entries, so that programs (and users) can derive basic context and meaning from
114 the identifiers as passed in `LoaderEntries`, `LoaderEntryDefault`,
115 `LoaderEntryOneShot`, `LoaderEntrySelected`, and possibly show nicely localized
116 names for them in UIs.
117
118 1. When boot loader entries are defined through the
119 [Boot Loader Specification](https://uapi-group.org/specifications/specs/boot_loader_specification/)
120 files, the identifier should be derived directly from the file name,
121 but with the `.conf` (Type #1 snippets) or `.efi` (Type #2 images)
122 suffix removed.
123
124 2. Entries automatically discovered by the boot loader (as opposed to being
125 configured in configuration files) should generally have an identifier
126 prefixed with `auto-`.
127
128 3. Boot menu entries referring to Microsoft Windows installations should either
129 use the identifier `windows` or use the `windows-` prefix for the
130 identifier. If a menu entry is automatically discovered, it should be
131 prefixed with `auto-`, see above (Example: this means an automatically
132 discovered Windows installation might have the identifier `auto-windows` or
133 `auto-windows-10` or so.).
134
135 4. Similarly, boot menu entries referring to Apple macOS installations should
136 use the identifier `osx` or one that is prefixed with `osx-`. If such an
137 entry is automatically discovered by the boot loader use `auto-osx` as
138 identifier, or `auto-osx-` as prefix for the identifier, see above.
139
140 5. If a boot menu entry encapsulates the EFI shell program, it should use the
141 identifier `efi-shell` (or when automatically discovered: `auto-efi-shell`,
142 see above).
143
144 6. If a boot menu entry encapsulates a reboot into EFI firmware setup feature,
145 it should use the identifier `reboot-to-firmware-setup` (or
146 `auto-reboot-to-firmware-setup` in case it is automatically discovered).
147
148 ## Links
149
150 [Boot Loader Specification](https://uapi-group.org/specifications/specs/boot_loader_specification)<br>
151 [Discoverable Partitions Specification](https://uapi-group.org/specifications/specs/discoverable_partitions_specification)<br>
152 [`systemd-boot(7)`](https://www.freedesktop.org/software/systemd/man/systemd-boot.html)<br>
153 [`bootctl(1)`](https://www.freedesktop.org/software/systemd/man/bootctl.html)<br>
154 [`systemd-gpt-auto-generator(8)`](https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html)