]> git.ipfire.org Git - thirdparty/systemd.git/blob - docs/BOOT_LOADER_SPECIFICATION.md
docs/BLS: describe version comparisons
[thirdparty/systemd.git] / docs / BOOT_LOADER_SPECIFICATION.md
1 ---
2 title: Boot Loader Specification
3 category: Booting
4 layout: default
5 SPDX-License-Identifier: LGPL-2.1-or-later
6 ---
7
8 # The Boot Loader Specification
9
10 This document defines a set of file formats and naming conventions that allow
11 the boot loader configuration to be shared between multiple operating systems
12 and boot loaders installed on one device.
13
14 Operating systems cooperatively manage a boot loader configuration directory
15 that contains drop-in files, making multi-boot scenarios easy to support. Boot
16 menu items are defined via a simple format that can be understood by different
17 boot loader implementations, operating systems, and userspace programs. The
18 same scheme can be used to prepare OS media for cases where the firmware
19 includes a boot loader.
20
21 ## Target audience
22
23 The target audience for this specification is:
24
25 * Boot loader developers, to write a boot loader that directly reads its
26 configuration from these files
27 * Firmware developers, to add generic boot loading support directly to the
28 firmware itself
29 * OS installer developers, to create appropriate partitions and set up the
30 initial boot loader configuration
31 * Distribution developers, to create appropriate configuration snippets when
32 installing or updating kernel packages
33 * UI developers, to implement user interfaces that list and select among the
34 available boot options
35
36 ## The boot partition
37
38 Everything described below is located on a file system that will be called
39 `$BOOT`. The boot loader or user-space programs reading the boot loader
40 configuration should pick `$BOOT` according to the following rules:
41
42 * On disks with an MBR partition table:
43
44 * A partition with the type ID of 0xEA shall be used as `$BOOT`.
45
46 * On disks with GPT (GUID Partition Table)
47
48 * If an Extended Boot Loader Partition (XBOOTLDR partition for short) — a
49 partition with GPT type GUID of `bc13c2ff-59e6-4262-a352-b275fd6f7172` —
50 is found, it should be used as `$BOOT`.
51
52 * Otherwise, the EFI System Partition (ESP for short) — a partition with
53 GPT type GUID of `c12a7328-f81f-11d2-ba4b-00a0c93ec93b` — should
54 be used as `$BOOT`.
55
56 An installer for the operating system should use this logic when selecting or
57 creating partitions:
58
59 * If `$BOOT` is not found, a new suitably sized partition (let's say 500MB)
60 should be created and used as `$BOOT`, matching the characteristics
61 described above. On disks with GPT, just an ESP partition without a
62 XBOOTLDR partition should be created.
63
64 * If the OS is installed on a disk with GPT and the ESP partition is found
65 but is too small, a new suitably sized (let's say 500MB) XBOOTLDR partition
66 shall be created and used as `$BOOT`.
67
68 This placeholder file system shall be determined during _installation time_,
69 and an fstab entry may be created. It should be mounted to either `/boot/` or
70 `/efi/`. Additional locations like `/boot/efi/` (with `/boot/` being a separate
71 file system) might be supported by implementations. This is not recommended
72 because the mounting of `$BOOT` is then dependent on and requires the mounting
73 of the intermediate file system.
74
75 **Note:** _`$BOOT` is **shared** among all OS installations of a system.
76 Instead of maintaining one `$BOOT` per installed OS (as `/boot/` was
77 traditionally handled), all installed OSes use the same place for boot-time
78 configuration._
79
80 For systems where the firmware is able to read file systems directly, `$BOOT`
81 must be a file system readable by the firmware. For other systems and generic
82 installation and live media, `$BOOT` must be a VFAT (16 or 32) file system.
83 Applications accessing `$BOOT` should hence not assume that fancier file system
84 features such as symlinks, hardlinks, access control or case sensitivity are
85 supported.
86
87 ## Boot loader entries
88
89 This specification defines two types of boot loader entries. The first type is
90 text based, very simple, and suitable for a variety of firmware, architecture
91 and image types ("Type #1"). The second type is specific to EFI, but allows
92 single-file images that embed all metadata in the kernel binary itself, which
93 is useful to cryptographically sign them as one file for the purpose of
94 SecureBoot ("Type #2").
95
96 Not all boot loader entries will apply to all systems. For example, Type #1
97 entries that use the `efi` key and all Type #2 entries only apply to EFI
98 systems. Entries using the `architecture` key might specify an architecture that
99 doesn't match the local one. Boot loaders should ignore all entries that don't
100 match the local platform and what the boot loader can support, and hide them
101 from the user. Only entries matching the feature set of boot loader and system
102 shall be considered and displayed. This allows image builders to put together
103 images that transparently support multiple different architectures.
104
105 Note that the `$BOOT` partition is not supposed to be exclusive territory of
106 this specification. This specification only defines semantics of the `/loader/`
107 directory inside the file system (see below), but it doesn't intend to define
108 ownership of the whole file system exclusively. Boot loaders, firmware, and
109 other software implementing this specification may choose to place other files
110 and directories in the same file system. For example, boot loaders that
111 implement this specification might install their own boot code on the same
112 partition; on systems where `$BOOT` is the ESP this is a particularly common
113 setup. Implementations of this specification must be able to operate correctly
114 if files or directories other than `/loader/` are found in the top level
115 directory. Implementations that add their own files or directories to the file
116 systems should use well-named directories, to make name collisions between
117 multiple users of the file system unlikely.
118
119 ### Type #1 Boot Loader Specification Entries
120
121 `$BOOT/loader/` is the main directory containing the configuration for the boot
122 loader.
123
124 **Note:** _In all cases the `/loader/` directory should be located directly in
125 the root of the file system. Specifically, if `$BOOT` is the ESP, then
126 `/loader/` directory should be located directly in the root directory of the
127 ESP, and not in the `/EFI/` subdirectory._
128
129 `$BOOT/loader/entries/` is the directory containing the drop-in snippets
130 defining boot entries, one `.conf` file for each boot menu item. Each OS may
131 provide one or more such entries.
132
133 The file name is used for identification of the boot item but shall never be
134 presented to the user in the UI. The file name may be chosen freely but should
135 be unique enough to avoid clashes between OS installations. More specifically,
136 it is suggested to include the `entry-token` (see
137 [kernel-install](https://www.freedesktop.org/software/systemd/man/kernel-install.html))
138 or machine ID (see
139 [/etc/machine-id](https://www.freedesktop.org/software/systemd/man/machine-id.html)),
140 and the kernel version (as returned by `uname -r`, including the OS
141 identifier), so that the whole filename is
142 `$BOOT/loader/entries/<entry-token-or-machine-id>-<version>.conf`.
143
144 Example: `$BOOT/loader/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf`.
145
146 In order to maximize compatibility with file system implementations and
147 restricted boot loader environments, and to minimize conflicting character use
148 with other programs, file names shall be chosen from a restricted character
149 set: ASCII upper and lower case characters, digits, "+", "-", "_" and ".".
150 Also, the file names should have a length of at least one and at most 255
151 characters (including the file name suffix).
152
153 These configuration snippets shall be UNIX-style text files (i.e. lines
154 separated by a single newline character), in the UTF-8 encoding. The
155 configuration snippets are loosely inspired by Grub1's configuration syntax.
156 Lines beginning with "#" are used for comments and shall be ignored. The first
157 word of a line is used as key and is separated by one or more spaces from the
158 value.
159
160 #### Type #1 Boot Loader Entry Keys
161
162 The following keys are recognized:
163
164 * `title` is a human-readable title for this menu item to be displayed in the
165 boot menu. It is a good idea to initialize this from the `PRETTY_NAME=` of
166 [os-release](https://www.freedesktop.org/software/systemd/man/os-release.html).
167 This name should be descriptive and does not have to be unique. If a boot
168 loader discovers two entries with the same title it should show more than
169 just the raw title in the UI, for example by appending the `version`
170 field. This field is optional.
171
172 Example: `title Fedora 18 (Spherical Cow)`
173
174 * `version` is a human-readable version for this menu item. This is usually the
175 kernel version and is intended for use by OSes to install multiple kernel
176 versions with the same `title` field. This field is used for sorting entries,
177 so that the boot loader can order entries by age or select the newest one
178 automatically. This field is optional.
179
180 See [Sorting](#sorting) below.
181
182 Example: `version 3.7.2-201.fc18.x86_64`
183
184 * `machine-id` is the machine ID of the OS. This can be used by boot loaders
185 and applications to filter out boot entries, for example to show only a
186 single newest kernel per OS, to group items by OS, or to filter out the
187 currently booted OS when showing only other installed operating systems.
188 This ID shall be formatted as 32 lower case hexadecimal characters
189 (i.e. without any UUID formatting). This key is optional.
190
191 Example: `machine-id 4098b3f648d74c13b1f04ccfba7798e8`
192
193 * `sort-key` is a short string used for sorting entries on display. This should
194 typically be initialized from the `IMAGE_ID=` or `ID=` fields of
195 [os-release](https://www.freedesktop.org/software/systemd/man/os-release.html),
196 possibly with an additional suffix. This field is optional.
197
198 Example: `sort-key fedora`
199
200 * `linux` is the Linux kernel to spawn and as a path relative to `$BOOT`. It
201 is recommended that every distribution creates a machine id and version
202 specific subdirectory below `$BOOT` and places its kernels and initial RAM
203 disk images there.
204
205 Example: `linux /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/linux`
206
207 * `initrd` is the initrd to use when executing the kernel. This also
208 shall be a path relative to `$BOOT`. This key is optional. This key may
209 appear more than once in which case all specified images are used, in the
210 order they are listed.
211
212 Example: `initrd 6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/initrd`
213
214 * `efi` refers to an arbitrary EFI program. This also takes a path relative to
215 `$BOOT`. If this key is set, and the system is not an EFI system this entry
216 should be hidden.
217
218 * `options` shall contain kernel parameters to pass to the Linux kernel to
219 spawn. This key is optional and may appear more than once in which case all
220 specified parameters are used in the order they are listed.
221
222 Example: `options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2 quiet`
223
224 * `devicetree` refers to the binary device tree to use when executing the
225 kernel. This also shall be a path relative to `$BOOT`. This key is
226 optional.
227
228 Example: `devicetree 6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.armv7hl/tegra20-paz00.dtb`
229
230 * `devicetree-overlay` refers to a list of device tree overlays that should be
231 applied by the boot loader. Multiple overlays are separated by spaces and
232 applied in the same order as they are listed. This key is optional but
233 depends on the `devicetree` key.
234
235 Example: `devicetree-overlay /6a9857a393724b7a981ebb5b8495b9ea/overlays/overlay_A.dtbo /6a9857a393724b7a981ebb5b8495b9ea/overlays/overlay_B.dtbo`
236
237 * `architecture` refers to the architecture this entry is for. The argument
238 should be an architecture identifier, using the architecture vocabulary
239 defined by the EFI specification (i.e. `IA32`, `x64`, `IA64`, `ARM`, `AA64`,
240 …). If specified and it does not match the local system architecture this
241 entry should be hidden. The comparison should be done case-insensitively.
242
243 Example: `architecture aa64`
244
245 Each configuration drop-in snippet must include at least a `linux` or an `efi`
246 key. Here is an example for a complete drop-in file:
247
248 # /boot/loader/entries/6a9857a393724b7a981ebb5b8495b9ea-3.8.0-2.fc19.x86_64.conf
249 title Fedora 19 (Rawhide)
250 sort-key fedora
251 machine-id 6a9857a393724b7a981ebb5b8495b9ea
252 version 3.8.0-2.fc19.x86_64
253 options root=UUID=6d3376e4-fc93-4509-95ec-a21d68011da2 quiet
254 architecture x64
255 linux /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/linux
256 initrd /6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/initrd
257
258 On EFI systems all Linux kernel images should be EFI images. In order to
259 increase compatibility with EFI systems it is highly recommended only to
260 install EFI kernel images, even on non-EFI systems, if that's applicable and
261 supported on the specific architecture.
262
263 Conversely, in order to increase compatibility it is recommended to install
264 generic kernel images that make few assumptions about the firmware they run on,
265 i.e. it is a good idea that both images shipped as UEFI PE images and those
266 which are not don't make unnecessary assumption on the underlying firmware,
267 i.e. don't hard depend on legacy BIOS calls or UEFI boot services.
268
269 When Type #1 configuration snippets refer to other files (for `linux`,
270 `initrd`, `efi`, `devicetree`, and `devicetree-overlay`), those files must be
271 located on the same partition. The naming of those files can be chosen by
272 the installer. A recommended scheme is described in the next section.
273
274 ### Recommended Directory Layout for Additional Files
275
276 It is recommened to place the kernel and other other files comprising a single
277 boot loader entry in a separate directory:
278 `/<entry-token-or-machine-id>/<version>/`. This naming scheme uses the same
279 elements as the boot loader configuration snippet, providing the same level of
280 uniqueness.
281
282 Example: `$BOOT/6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/linux`
283 `$BOOT/6a9857a393724b7a981ebb5b8495b9ea/3.8.0-2.fc19.x86_64/initrd`
284
285 Other naming schemes are possible. In particular, traditionally a flat naming
286 scheme with files in the root directory was used. This is not recommended
287 because it is hard to avoid conflicts in a multi-boot installation.
288
289 ### Standard-conformance Marker File
290
291 Unfortunately, there are implementations of boot loading infrastructure that
292 are also using the `/loader/entries/` directory, but installing files that do
293 not follow this specification. In order to minimize confusion, a boot loader
294 implementation may place the file `/loader/entries.srel` next to the
295 `/loader/entries/` directory containing the ASCII string `type1` (followed by a
296 UNIX newline). Tools that need to determine whether an existing directory
297 implements the semantics described here may check for this file and contents:
298 if it exists and contains the mentioned string, it shall assume a
299 standards-compliant implementation is in place. If it exists but contains a
300 different string it shall assume other semantics are implemented. If the file
301 does not exist, no assumptions should be made.
302
303 ### Type #2 EFI Unified Kernel Images
304
305 A unified kernel image is a single EFI PE executable combining an EFI stub
306 loader, a kernel image, an initramfs image, and the kernel command line. See
307 the description of the `--uefi` option in
308 [dracut(8)](http://man7.org/linux/man-pages/man8/dracut.8.html). Such unified
309 images are installed in the`$BOOT/EFI/Linux/` directory and must have the
310 extension `.efi`. Support for images of this type is of course specific to
311 systems with EFI firmware. Ignore this section if you work on systems not
312 supporting EFI.
313
314 Type #2 file names should be chosen from the same restricted character set as
315 Type #1 described above (but with the file name suffix of `.efi` instead of
316 `.conf`).
317
318 Images of this type have the advantage that all metadata and payload that makes
319 up the boot entry is contained in a single PE file that can be signed
320 cryptographically as one for the purpose of EFI SecureBoot.
321
322 A valid unified kernel image must contain two PE sections:
323
324 * `.cmdline` section with the kernel command line,
325 * `.osrel` section with an embedded copy of the
326 [os-release](https://www.freedesktop.org/software/systemd/man/os-release.html)
327 file describing the image.
328
329 The `PRETTY_NAME=` and `VERSION_ID=` fields in the embedded `os-release` file
330 are used the same as `title` and `version` in the Type #1 entries. The
331 `.cmdline` section is used instead of the `options` field. `linux` and `initrd`
332 fields are not necessary, and there is no counterpart for the `machine-id`
333 field.
334
335 On EFI, any such images shall be added to the list of valid boot entries.
336
337 ### Additional notes
338
339 Note that these configurations snippets do not need to be the only
340 configuration source for a boot loader. It may extend this list of entries with
341 additional items from other configuration files (for example its own native
342 configuration files) or automatically detected other entries without explicit
343 configuration.
344
345 To make this explicitly clear: this specification is designed with "free"
346 operating systems in mind, starting Windows or macOS is out of focus with these
347 configuration snippets, use boot-loader specific solutions for that. In the
348 text above, if we say "OS" we hence imply "free", i.e. primarily Linux (though
349 this could be easily be extended to the BSDs and whatnot).
350
351 Note that all paths used in the configuration snippets use a Unix-style "/" as
352 path separator. This needs to be converted to an EFI-style "\\" separator in
353 EFI boot loaders.
354
355
356 ## Locating boot entries
357
358 A _boot loader_ locates `$BOOT`, then simply reads all files
359 `$BOOT/loader/entries/*.conf`, and populates its boot menu with this. On EFI,
360 it then extends this with any unified kernel images found in
361 `$BOOT/EFI/Linux/*.efi`. It may also add additional entries, for example a
362 "Reboot into firmware" option. Optionally it may sort the menu based on the
363 `sort-key`, `machine-id` and `version` fields, and possibly others. It uses the
364 file name to identify specific items, for example in case it supports storing
365 away default entry information somewhere. A boot loader should generally not
366 modify these files.
367
368 For "Boot Loader Specification Entries" (Type #1), the _kernel package
369 installer_ installs the kernel and initrd images to `$BOOT` (it is recommended
370 to place these files in a vendor and OS and installation specific directory)
371 and then generates a configuration snippet for it, placing this in
372 `$BOOT/loader/entries/xyz.conf`, with "xyz" as concatenation of machine id and
373 version information (see above). The files created by a kernel package are tied
374 to the kernel package and should be removed along with it.
375
376 For "EFI Unified Kernel Images" (Type #2), the vendor or kernel package
377 installer should create the combined image and drop it into
378 `$BOOT/EFI/Linux/`. This file is also tied to the kernel package and should be
379 removed along with it.
380
381 A _UI application_ intended to show available boot options shall operate
382 similarly to a boot loader, but might apply additional filters, for example by
383 filtering the booted OS via the machine ID, or by suppressing all but the
384 newest kernel versions.
385
386 An _OS installer_ picks the right place for `$BOOT` as defined above (possibly
387 creating a partition and file system for it) and creates the `/loader/entries/`
388 directory in it. It then installs an appropriate boot loader that can read
389 these snippets. Finally, it installs one or more kernel packages.
390
391 ## Sorting
392
393 The boot loader menu should generally show entries in some order meaningful to
394 the user. The `title` key is free-form and not suitable to be used as the
395 primary sorting key. Instead, the boot loader should use the following rules:
396 if `sort-key` is set on both entries, use in order of priority,
397 the `sort-key` (A-Z, increasing [alphanumerical order](#alphanumerical-order)),
398 `machine-id` (A-Z, increasing alphanumerical order),
399 and `version` keys (decreasing [version order](#version-order)).
400 If `sort-key` is set on one entry, it sorts earlier.
401 At the end, if necessary, when `sort-key` is not set or those fields are not
402 set or are all equal, the boot loader should sort using the file name of the
403 entry (decreasing version sort), with the suffix removed.
404
405 **Note:** _This description assumes that the boot loader shows entries in a
406 traditional menu, with newest and "best" entries at the top, thus entries with
407 a higher version number are sorter *earlier*. The boot loader is free to
408 use a different direction (or none at all) during display._
409
410 ### Alphanumerical order
411
412 Free-form strings and machine IDs should be compared using a method equivalent
413 to [strcmp(3)](https://man7.org/linux/man-pages/man3/strcmp.3.html) on their
414 UTF-8 represenations. If just one of the strings is unspecified or empty, it
415 compares lower. If both strings are unspecified or empty, they compare equal.
416
417 ### Version order
418
419 The following method should be used to compare version strings. The algorithm
420 is based on rpm's `rpmvercmp()`, but not identical.
421
422 ASCII letters (`a-z`, `A-Z`) and digits (`0-9`) form alphanumerical components of the version.
423 Minus (`-`) separates the version and release parts.
424 Dot (`.`) separates parts of version or release.
425 Tilde (`~`) is a prefix that always compares lower.
426 Caret (`^`) is a prefix that always compares higher.
427
428 Both strings are compared from the beginning until the end, or until the
429 strings are found to compare as different. In a loop:
430 1. Any characters which are outside of the set of listed above (`a-z`, `A-Z`, `0-9`, `-`, `.`, `~`, `^`)
431 are skipped in both strings. In particular, this means that non-ASCII characters
432 that are Unicode digits or letters are skipped too.
433 2. If one of the strings has ended: if the other string hasn't, the string that
434 has remaining characters compares higher. Otherwise, the strings compare
435 equal.
436 3. If the remaining part of one of strings starts with `~`:
437 if other remaining part does not start with `~`,
438 the string with `~` compares lower. Otherwise, both tilde characters are skipped.
439 4. The check from point 2. is repeated here.
440 5. If the remaining part of one of strings starts with `-`:
441 if the other remaining part does not start with `-`,
442 the string with `-` compares lower. Otherwise, both minus characters are skipped.
443 6. If the remaining part of one of strings starts with `^`:
444 if the other remaining part does not start with `^`,
445 the string with `^` compares higher. Otherwise, both caret characters are skipped.
446 6. If the remaining part of one of strings starts with `.`:
447 if the other remaining part does not start with `.`,
448 the string with `.` compares lower. Otherwise, both dot characters are skipped.
449 7. If either of the remaining parts starts with a digit, numerical prefixes are
450 compared numerically. Any leading zeroes are skipped.
451 The numerical prefixes (until the first non-digit character) are evaluated as numbers.
452 If one of the prefixes is empty, it evaluates as 0.
453 If the numbers are different, the string with the bigger number compares higher.
454 Otherwise, the comparison continues at the following characters at point 1.
455 8. Leading alphabetical prefixes are compared alphabetically.
456 The substrings are compared letter-by-letter.
457 If both letters are the same, the comparison continues with the next letter.
458 Capital letters compare lower than lower-case letters (`A < a`).
459 When the end of one substring has been reached (a non-letter character or the end
460 of the whole string), if the other substring has remaining letters, it compares higher.
461 Otherwise, the comparison continues at the following characters at point 1.
462
463 Examples (with '' meaning the empty string):
464
465 * `11 == 11`
466 * `systemd-123 == systemd-123`
467 * `bar-123 < foo-123`
468 * `123a > 123`
469 * `123.a > 123`
470 * `123.a < 123.b`
471 * `123a > 123.a`
472 * `11α == 11β`
473 * `A < a`
474 * '' < `0`
475 * `0.` > `0`
476 * `0.0` > `0`
477 * `0` < `~`
478 * '' < `~`
479
480 Note: [systemd-analyze](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html)
481 implements this version comparison algorithm as
482 ```
483 systemd-analyze compare-versions <version-a> <version-b>
484 ```
485
486 ## Additional discussion
487
488 ### Why is there a need for this specification?
489
490 This specification brings the following advantages:
491
492 * Installation of new boot entries is more robust, as no explicit rewriting of
493 configuration files is required.
494
495 * It allows an out-of-the-box boot experience on any platform without the need
496 of traditional firmware mechanisms (e.g. BIOS calls, UEFI Boot Services).
497
498 * It improves dual-boot scenarios. Without cooperation, multiple Linux
499 installations tend to fight over which boot loader becomes the primary one in
500 possession of the MBR or the boot partition, and only that one installation
501 can then update the boot loader configuration. Other Linux installs have to
502 be manually configured to never touch the MBR and instead install a
503 chain-loaded boot loader in their own partition headers. In this new scheme
504 all installations share a loader directory and no manual configuration has to
505 take place. All participants implicitly cooperate due to removal of name
506 collisions and can install/remove their own boot menu entries without
507 interfering with the entries of other installed operating systems.
508
509 * Drop-in directories are now pretty ubiquitous on Linux as an easy way to
510 extend configuration without having to edit, regenerate or manipulate
511 configuration files. For the sake of uniformity, we should do the same for
512 the boot menu.
513
514 * Userspace code can sanely parse boot loader configuration which is essential
515 with modern firmware which does not necessarily initialize USB keyboards
516 during boot, which makes boot menus hard to reach for the user. If userspace
517 code can parse the boot loader configuration too, UI can be written that
518 select a boot menu item to boot into before rebooting the machine, thus not
519 requiring interactivity during early boot.
520
521 * To unify and thus simplify configuration of the various boot loaders, which
522 makes configuration of the boot loading process easier for users,
523 administrators, and developers alike.
524
525 * For boot loaders with configuration _scripts_ such as grub2, adopting this
526 spec allows for mostly static scripts that are generated only once at first
527 installation, but then do not need to be updated anymore as that is done via
528 drop-in files exclusively.
529
530 ### Why not simply rely on the EFI boot menu logic?
531
532 EFI is not ubiquitous, especially not in embedded systems. But even on systems
533 with EFI, which provides a boot options logic that can offer similar
534 functionality, this specfication is still needed for the following reasons:
535
536 * The various EFI implementations implement the boot order/boot item logic to
537 different levels. Some firmware implementations do not offer a boot menu at
538 all and instead unconditionally follow the EFI boot order, booting the first
539 item that is working.
540
541 * If the firmware setup is used to reset data, usually all EFI boot entries
542 are lost, making the system entirely unbootable, as the firmware setups
543 generally do not offer a UI to define additional boot items. By placing the
544 menu item information on disk, it is always available, even if the firmware
545 configuration is lost.
546
547 * Harddisk images should be movable between machines and be bootable without
548 requiring firmare configuration. This also requires that the list
549 of boot options is defined on disk, and not in EFI variables alone.
550
551 * EFI is not universal yet (especially on non-x86 platforms), this
552 specification is useful both for EFI and non-EFI boot loaders.
553
554 * Many EFI systems disable USB support during early boot to optimize boot
555 times, thus making keyboard input unavailable in the EFI menu. It is thus
556 useful if the OS UI has a standardized way to discover available boot options
557 which can be booted to.
558
559 ### Why is the version comparsion logic so complicated?
560
561 The `sort-key` allows us to group entries by "operating system", e.g. all
562 versions of Fedora together, no matter if they identify themselves as "Fedora
563 Workstation" or "Fedora Rawhide (prerelease)". The `sort-key` was introduced
564 only recently, so we need to provide a meaningful order for entries both with
565 and without it. Since it is a new concept, it is assumed that entries with
566 `sort-key` are newer.
567
568 In a traditional menu with entries displayed vertically, we want names to be
569 sorter alpabetically (CentOS, Debian, Fedora, OpenSUSE, …), it would be strange
570 to have them in reverse order. But when multiple kernels are available for the
571 same installation, we want to display the latest kernel with highest priority,
572 i.e. earlier in the list.
573
574 ### Out of Focus
575
576 There are a couple of items that are out of focus for this specification:
577
578 * If userspace can figure out the available boot options, then this is only
579 useful so much: we'd still need to come up with a way how userspace could
580 communicate to the boot loader the default boot loader entry temporarily or
581 persistently. Defining a common scheme for this is certainly a good idea, but
582 out of focus for this specification.
583
584 * This specification is just about "Free" Operating systems. Hooking in other
585 operating systems (like Windows and macOS) into the boot menu is a different
586 story and should probably happen outside of this specification. For example,
587 boot loaders might choose to detect other available OSes dynamically at
588 runtime without explicit configuration (like `systemd-boot` does it), or via
589 native configuration (for example via explicit Grub2 configuration generated
590 once at installation).
591
592 * This specification leaves undefined what to do about systems which are
593 upgraded from an OS that does not implement this specification. As the
594 previous boot loader logic was largely handled by in distribution-specific
595 ways we probably should leave the upgrade path (and whether there actually is
596 one) to the distributions. The simplest solution might be to simply continue
597 with the old scheme for old installations and use this new scheme only for
598 new installations.
599
600 * Referencing kernels or initrds on other partitions other than the partition
601 containing the Type #1 boot loader entry. This is by design, as specifying
602 other partitions or devices would require a non-trivial language for denoting
603 device paths. In particular this means that on non-EFI systems configuration
604 snippets following this specification cannot be used to spawn other operating
605 systems (such as Windows).
606
607
608 ## Links
609
610 [GUID Partition Table](https://en.wikipedia.org/wiki/GUID_Partition_Table)<br>
611 [Boot Loader Interface](BOOT_LOADER_INTERFACE.md)<br>
612 [Discoverable Partitions Specification](DISCOVERABLE_PARTITIONS.md)<br>
613 [`systemd-boot(7)`](https://www.freedesktop.org/software/systemd/man/systemd-boot.html)<br>
614 [`bootctl(1)`](https://www.freedesktop.org/software/systemd/man/bootctl.html)<br>
615 [`systemd-gpt-auto-generator(8)`](https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html)