]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/BOOT_LOADER_INTERFACE.md
Merge pull request #32324 from mrc0mmand/more-website-fixes
[thirdparty/systemd.git] / docs / BOOT_LOADER_INTERFACE.md
CommitLineData
c3e270f4 1---
a0fadf66 2title: Boot Loader Interface
4cdca0af 3category: Booting
b41a3f66 4layout: default
0aff7b75 5SPDX-License-Identifier: LGPL-2.1-or-later
c3e270f4
FB
6---
7
2fe82132
LP
8# The Boot Loader Interface
9
10systemd can interface with the boot loader to receive performance data and
11other information, and pass control information. This is only supported on EFI
12systems. Data is transferred between the boot loader and systemd in EFI
13variables. 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
3f9a0a52 31* The EFI variable `LoaderConfigTimeout` contains the boot menu timeout
2fe82132
LP
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
b9de6a7b
EV
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`
97f077df
JJ
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.
6efdd7fe
EV
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.
2fe82132
LP
41
42* Similarly, the EFI variable `LoaderConfigTimeoutOneShot` contains a boot menu
3f9a0a52 43 timeout for a single following boot. It is set by the OS in order to request
2fe82132
LP
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
3f9a0a52 48 timeout is turned off, and the menu is shown indefinitely.
2fe82132
LP
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
da890466 72* The EFI variable `LoaderFeatures` contains a 64-bit unsigned integer with a
2fe82132
LP
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.
0d592a5e 81 * `1 << 4` → The boot loader supports boot counting as described in [Automatic Boot Assessment](/AUTOMATIC_BOOT_ASSESSMENT).
c7bb4dfc 82 * `1 << 5` → The boot loader supports looking for boot menu entries in the Extended Boot Loader Partition.
22aba2b9 83 * `1 << 6` → The boot loader supports passing a random seed to the OS.
6efdd7fe 84 * `1 << 13` → The boot loader honours `menu-disabled` option when set.
c7bb4dfc 85
c7bb4dfc
LP
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.
2fe82132
LP
99
100If `LoaderTimeInitUSec` and `LoaderTimeExecUSec` are set, `systemd-analyze`
101will include them in its boot-time analysis. If `LoaderDevicePartUUID` is set,
102systemd will mount the ESP that was used for the boot to `/boot`, but only if
103that directory is empty, and only if no other file systems are mounted
104there. The `systemctl reboot --boot-loader-entry=…` and `systemctl reboot
105--boot-loader-menu=…` commands rely on the `LoaderFeatures` ,
c7bb4dfc 106`LoaderConfigTimeoutOneShot`, `LoaderEntries`, `LoaderEntryOneShot`
0be72218 107variables.
f7f00fb1
LP
108
109## Boot Loader Entry Identifiers
110
111While boot loader entries may be named relatively freely, it's highly
112recommended to follow the following rules when picking identifiers for the
113entries, so that programs (and users) can derive basic context and meaning from
114the identifiers as passed in `LoaderEntries`, `LoaderEntryDefault`,
115`LoaderEntryOneShot`, `LoaderEntrySelected`, and possibly show nicely localized
116names for them in UIs.
117
db811444
ZJS
1181. When boot loader entries are defined through the
119 [Boot Loader Specification](https://uapi-group.org/specifications/specs/boot_loader_specification/)
2bd051a0
ZJS
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)
db811444 122 suffix removed.
f7f00fb1
LP
123
1242. 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
1283. 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
2bd051a0 1354. Similarly, boot menu entries referring to Apple macOS installations should
f7f00fb1
LP
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
1405. 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
1446. 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).
b0cda241
ZJS
147
148## Links
149
db811444
ZJS
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>
a43d2229
LP
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)