]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-stub.xml
Preset user units on first boot as well
[thirdparty/systemd.git] / man / systemd-stub.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-stub" conditional='ENABLE_BOOTLOADER'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8 <refentryinfo>
9 <title>systemd-stub</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd-stub</refentrytitle>
15 <manvolnum>7</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd-stub</refname>
20 <refname>sd-stub</refname>
21 <refname>linuxx64.efi.stub</refname>
22 <refname>linuxia32.efi.stub</refname>
23 <refname>linuxaa64.efi.stub</refname>
24 <refpurpose>A simple UEFI kernel boot stub</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <para><simplelist>
29 <member><filename>/usr/lib/systemd/boot/efi/linuxx64.efi.stub</filename></member>
30 <member><filename>/usr/lib/systemd/boot/efi/linuxia32.efi.stub</filename></member>
31 <member><filename>/usr/lib/systemd/boot/efi/linuxaa64.efi.stub</filename></member>
32 <member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.addon.efi</filename></member>
33 <member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.cred</filename></member>
34 <member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.raw</filename></member>
35 <member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.sysext.raw</filename></member>
36 <member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.confext.raw</filename></member>
37 <member><filename><replaceable>ESP</replaceable>/loader/addons/*.addon.efi</filename></member>
38 <member><filename><replaceable>ESP</replaceable>/loader/credentials/*.cred</filename></member>
39 </simplelist></para>
40 </refsynopsisdiv>
41
42 <refsect1>
43 <title>Description</title>
44
45 <para><command>systemd-stub</command> (stored in per-architecture files
46 <filename>linuxx64.efi.stub</filename>, <filename>linuxia32.efi.stub</filename>,
47 <filename>linuxaa64.efi.stub</filename> on disk) is a simple UEFI boot stub. An UEFI boot stub is
48 attached to a Linux kernel binary image, and is a piece of code that runs in the UEFI firmware
49 environment before transitioning into the Linux kernel environment. The UEFI boot stub ensures a Linux
50 kernel is executable as regular UEFI binary, and is able to do various preparations before switching the
51 system into the Linux world.</para>
52
53 <para>The UEFI boot stub looks for various resources for the kernel invocation inside the UEFI PE binary
54 itself. This allows combining various resources inside a single PE binary image (usually called "Unified
55 Kernel Image", or "UKI" for short), which may then be signed via UEFI SecureBoot as a whole, covering all
56 individual resources at once. Specifically it may include the following PE sections:</para>
57
58 <itemizedlist>
59 <!-- Let's keep this in the canonical order we also measure the sections by, i.e. as in
60 src/fundamental/uki.h's UnifiedSection enum -->
61
62 <listitem><para>A <literal>.linux</literal> section with the ELF Linux kernel
63 image. (Required)</para></listitem>
64
65 <listitem><para>An <literal>.osrel</literal> section with OS release information, i.e. the contents of
66 the <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file
67 of the OS the kernel belongs to.</para></listitem>
68
69 <listitem><para>A <literal>.cmdline</literal> section with the kernel command line to pass to the
70 invoked kernel.</para></listitem>
71
72 <listitem><para>An <literal>.initrd</literal> section with the initrd.</para></listitem>
73
74 <listitem><para>A <literal>.ucode</literal> section with an initrd containing microcode, to be handed
75 to the kernel before any other initrd. This initrd must not be compressed.</para></listitem>
76
77 <listitem><para>A <literal>.splash</literal> section with an image (in the Windows
78 <filename>.BMP</filename> format) to show on screen before invoking the kernel.</para></listitem>
79
80 <listitem><para>A <literal>.dtb</literal> section with a compiled binary DeviceTree.</para></listitem>
81
82 <listitem><para>A <literal>.uname</literal> section with the kernel version information, i.e. the
83 output of <command>uname -r</command> for the kernel included in the <literal>.linux</literal>
84 section.</para></listitem>
85
86 <listitem><para>An <literal>.sbat</literal> section with
87 <ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">SBAT</ulink> revocation
88 metadata.</para></listitem>
89
90 <listitem><para>A <literal>.pcrsig</literal> section with a set of cryptographic signatures for the
91 expected TPM2 PCR values after the kernel has been booted, in JSON format. This is useful for
92 implementing TPM2 policies that bind disk encryption and similar to kernels that are signed by a
93 specific key.</para></listitem>
94
95 <listitem><para>A <literal>.pcrpkey</literal> section with a public key in the PEM format matching the
96 signature data in the <literal>.pcrsig</literal> section.</para></listitem>
97 </itemizedlist>
98
99 <para>Generally, the sections above should appear at most once in a UKI. That said, a concept of
100 "profiles" is defined, that allows multiple sets of these sections to exist in a single UKI file, of
101 which one can be selected at boot. For this an additional PE section <literal>.profile</literal> is
102 defined which can be used as separator between multiple sets of these settings. The
103 <literal>.profile</literal> section itself may contain meta-information about the section, and follows a
104 similar structure as the contents of the <literal>.osrel</literal> section. For further details about
105 multi-profile UKIs, see below.</para> <para>If UEFI SecureBoot is enabled and the
106 <literal>.cmdline</literal> section is present in the executed image, any attempts to override the kernel
107 command line by passing one as invocation parameters to the EFI binary are ignored. Thus, in order to
108 allow overriding the kernel command line, either disable UEFI SecureBoot, or don't include a kernel
109 command line PE section in the kernel image file. If a command line is accepted via EFI invocation
110 parameters to the EFI binary it is measured into TPM PCR 12 (if a TPM is present).</para> <para>If a
111 DeviceTree is embedded in the <literal>.dtb</literal> section, it replaces an existing DeviceTree in the
112 corresponding EFI configuration table. systemd-stub will ask the firmware via the
113 <literal>EFI_DT_FIXUP_PROTOCOL</literal> for hardware specific fixups to the DeviceTree.</para> <para>The
114 contents of 11 of these 12 sections are measured into TPM PCR 11. It is otherwise not used and thus the
115 result can be pre-calculated without too much effort. The <literal>.pcrsig</literal> section is not
116 included in this PCR measurement, since it is supposed to contain signatures for the output of the
117 measurement operation, and thus cannot also be input to it. If an UKI contains multiple profiles, only
118 the PE sections of the selected profile (and those of the base profile, except if overridden) are
119 measured.</para>
120
121 <para>If non-zero, the selected numeric profile is measured into PCR 12.</para>
122
123 <para>When <literal>.pcrsig</literal> and/or <literal>.pcrpkey</literal> sections are present in a
124 unified kernel image their contents are passed to the booted kernel in an synthetic initrd cpio archive
125 that places them in the <filename>/.extra/tpm2-pcr-signature.json</filename> and
126 <filename>/.extra/tpm2-pcr-public-key.pem</filename> files. Typically, a
127 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line then
128 ensures they are copied into <filename>/run/systemd/tpm2-pcr-signature.json</filename> and
129 <filename>/run/systemd/tpm2-pcr-public-key.pem</filename> where they remain accessible even after the
130 system transitions out of the initrd environment into the host file system. Tools such
131 <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
133 and <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>
134 will automatically use files present under these paths to unlock protected resources (encrypted storage
135 or credentials) or bind encryption to booted kernels.</para>
136
137 <para>For further details about the UKI concept, see the <ulink
138 url="https://uapi-group.org/specifications/specs/unified_kernel_image/">UKI specification</ulink>.</para>
139 </refsect1>
140
141 <refsect1>
142 <title>Companion Files</title>
143
144 <para>The <command>systemd-stub</command> UEFI boot stub automatically collects three types of auxiliary
145 companion files optionally placed in drop-in directories on the same partition as the EFI binary,
146 dynamically generates <command>cpio</command> initrd archives from them, and passes them to the kernel.
147 Specifically:</para>
148
149 <itemizedlist>
150 <listitem><para>For a kernel binary called <filename><replaceable>foo</replaceable>.efi</filename>, it
151 will look for files with the <filename>.cred</filename> suffix in a directory named
152 <filename><replaceable>foo</replaceable>.efi.extra.d/</filename> next to it. If the kernel binary
153 uses a counter for the purpose of
154 <ulink url="https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT">Automatic Boot Assessment</ulink>, this
155 counter will be ignored. For example, <filename><replaceable>foo</replaceable>+3-0.efi</filename>
156 will look in directory <filename><replaceable>foo</replaceable>.efi.extra.d/</filename>.
157 A <command>cpio</command>
158 archive is generated from all files found that way, placing them in the
159 <filename>/.extra/credentials/</filename> directory of the initrd file hierarchy. The main initrd may
160 then access them in this directory. This is supposed to be used to store auxiliary, encrypted,
161 authenticated credentials for use with <varname>LoadCredentialEncrypted=</varname> in the UEFI System
162 Partition. See
163 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
164 and
165 <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>
166 for
167 details on encrypted credentials. The generated <command>cpio</command> archive is measured into TPM
168 PCR 12 (if a TPM is present).</para></listitem>
169
170 <listitem><para>Similarly, files
171 <filename><replaceable>foo</replaceable>.efi.extra.d/*.sysext.raw</filename> are packed up in a
172 <command>cpio</command> archive and placed in the <filename>/.extra/sysext/</filename> directory in the
173 initrd file hierarchy. This is supposed to be used to pass additional system extension images to the
174 initrd. See
175 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
176 details on system extension images. The generated <command>cpio</command> archive containing these
177 system extension images is measured into TPM PCR 13 (if a TPM is present).</para></listitem>
178
179 <!-- Note: the actual suffix we look for for sysexts is just *.raw (not *.sysext.raw), for
180 compatibility reasons with old versions. But we want people to name their system extensions
181 properly, hence we document the *.sysext.raw suffix only. -->
182
183 <listitem><para>Similarly, files
184 <filename><replaceable>foo</replaceable>.efi.extra.d/*.confext.raw</filename> are packed up in a
185 <command>cpio</command> archive and placed in the <filename>/.extra/confext/</filename> directory in
186 the initrd file hierarchy. This is supposed to be used to pass additional configuration extension
187 images to the initrd. See
188 <citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
189 details on configuration extension images. The generated <command>cpio</command> archive containing
190 these system extension images is measured into TPM PCR 12 (if a TPM is present).</para></listitem>
191
192 <listitem><para>Similarly, files
193 <filename><replaceable>foo</replaceable>.efi.extra.d/*.addon.efi</filename> are loaded and verified as
194 PE binaries, and a <literal>.cmdline</literal> or <literal>.ucode</literal> section is parsed from them.
195 Addons are supposed to be used to pass additional kernel command line parameters, or Devicetree blobs,
196 and microcode updates, regardless of the kernel image being booted, for example to allow platform vendors
197 to ship platform-specific configuration.</para>
198
199 <para>In case Secure Boot is enabled, these files will be validated using keys in UEFI DB, Shim's DB or
200 Shim's MOK, and will be rejected otherwise. Additionally, if both the addon and the UKI contain a
201 <literal>.uname</literal> section, the addon will be rejected if they do not match exactly. It is
202 recommended to always add a <literal>.sbat</literal> section to all signed addons, so that they may be
203 revoked with a SBAT policy update, without requiring blocklisting via DBX/MOKX. The
204 <citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool will add
205 a SBAT policy by default if none is passed when building addons. For more information on SBAT see
206 <ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">Shim documentation</ulink>.</para>
207
208 <para>Addon files are sorted, loaded, and measured into TPM PCR 12 (if a TPM is present) and appended
209 to the kernel command line. UKI command line options are listed first, then options from addons in
210 <filename>/loader/addons/*.addon.efi</filename>, and finally UKI-specific addons. Device tree blobs are
211 loaded and measured following the same algorithm. Microcode addons are passed to the kernel in inverse
212 order (UKI specific addons, global addons, UKI embedded section). This is because the microcode update
213 driver stops on the first matching filename. Addons are always loaded in the same order based on
214 the filename, so that, given the same set of addons, the same set of measurements can be expected in
215 PCR12. However, note that the filename is not protected by the PE signature, and as such an attacker
216 with write access to the ESP could potentially rename these files to change the order in which they are
217 loaded, in a way that could alter the functionality of the kernel, as some options might be
218 order-dependent. If you sign such addons, you should pay attention to the PCR12 values and make use of
219 an attestation service so that improper use of your signed addons can be detected and dealt with using
220 one of the aforementioned revocation mechanisms.</para></listitem>
221
222 <listitem><para>Files <filename>/loader/credentials/*.cred</filename> are packed up in a
223 <command>cpio</command> archive and placed in the <filename>/.extra/global_credentials/</filename>
224 directory of the initrd file hierarchy. This is supposed to be used to pass additional credentials to
225 the initrd, regardless of the kernel being booted. The generated <command>cpio</command> archive is
226 measured into TPM PCR 12 (if a TPM is present).</para></listitem>
227
228 <listitem><para>Additionally, files <filename>/loader/addons/*.addon.efi</filename> are loaded and
229 verified as PE binaries, and <literal>.cmdline</literal>, <literal>.dtb</literal> and/or
230 <literal>.ucode</literal>sections are parsed from them. This is supposed to be used to pass additional
231 command line parameters, Devicetree blobs and microcode updates to the kernel, regardless of the
232 kernel being booted.</para></listitem>
233 </itemizedlist>
234
235 <para>These mechanisms may be used to parameterize and extend trusted (i.e. signed), immutable initrd
236 images in a reasonably safe way: all data they contain is measured into TPM PCRs. On access they should be
237 further validated: in case of the credentials case by encrypting/authenticating them via TPM, as exposed
238 by <command>systemd-creds encrypt -T</command> (see
239 <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
240 details); in case of the system extension images by using signed Verity images.</para>
241 </refsect1>
242
243 <refsect1>
244 <title>Multi-Profile UKIs</title>
245
246 <para>In many contexts it is useful to allow invocation of a single UKI in multiple different modes (or
247 "profiles") without compromising the cryptographic integrity, measurements and so on of the boot
248 process. For example, a single UKI might provide three distinct profiles: a regular boot one, one that
249 invokes a "factory reset" operation, and one that boots into a storage target mode (as in
250 <citerefentry><refentrytitle>systemd-storagetm.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>). Each
251 profile would then use the same <literal>.linux</literal> and <literal>.initrd</literal> sections, but would
252 have a separate <literal>.cmdline</literal> section. For example the latter two profiles would extend the
253 regular kernel command line with <literal>systemd.unit=factory-reset.target</literal> or
254 <literal>rd.systemd.unit=storagetm.target</literal>.</para>
255
256 <para>A single UKI may support multiple profiles by means of the special <literal>.profile</literal> PE
257 section. This section acts as separator between the PE sections of the individual
258 profiles. <literal>.profile</literal> PE sections hence may appear multiple times in a single UKI, and
259 the other PE sections listed above may appear multiple times too, if <literal>.profile</literal> are
260 used, but only once before the first <literal>.profile</literal> section, once between each subsequent
261 pair, and once after the last appearance of <literal>.profile</literal>. The sections listed before the
262 first <literal>.profile</literal> are considered the "base" profile of the UKI. Each
263 <literal>.profile</literal> section then introduces a new profile, which are numbered starting from
264 zero. The PE sections following each <literal>.profile</literal> are specific to that profile. When
265 booting into a specific profile the base section's profiles are used in combination with the specific
266 profile's sections: if the same section is defined in both, the per-profile section overrides the base
267 profile's version, otherwise the per-profile sections is used together with the base profile
268 sections.</para> <para>A UKI that contains no <literal>.profile</literal> is consider equivalent to one
269 that just contains a single <literal>.profile</literal>, as having only a single profile @0.</para>
270
271 <para>Here's a simple example for a multi-profile UKI's sections, inspired by the setup suggested above:</para>
272
273 <table>
274 <title>Multi-Profile UKI Example</title>
275
276 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
277 <colspec colname="section" />
278 <colspec colname="profile" />
279
280 <thead>
281 <row>
282 <entry>Section</entry>
283 <entry>Profile</entry>
284 </row>
285 </thead>
286
287 <tbody>
288 <row>
289 <entry><literal>.linux</literal></entry>
290 <entry morerows="3" valign="middle">Base profile</entry>
291 </row>
292 <row>
293 <entry><literal>.osrel</literal></entry>
294 </row>
295 <row>
296 <entry><literal>.cmdline</literal></entry>
297 </row>
298 <row>
299 <entry><literal>.initrd</literal></entry>
300 </row>
301 <row>
302 <entry><literal>.profile</literal></entry>
303 <entry>Profile @0</entry>
304 </row>
305 <row>
306 <entry><literal>.profile</literal></entry>
307 <entry morerows="1" valign="middle">Profile @1</entry>
308 </row>
309 <row>
310 <entry><literal>.cmdline</literal></entry>
311 </row>
312 <row>
313 <entry><literal>.profile</literal></entry>
314 <entry morerows="1" valign="middle">Profile @2</entry>
315 </row>
316 <row>
317 <entry><literal>.cmdline</literal></entry>
318 </row>
319 </tbody>
320 </tgroup>
321 </table>
322
323 <para>The section list above would define three profiles. The first four sections make up the base
324 profile. A <literal>.profile</literal> section then introduces profile @0. It doesn't override any
325 sections (or add any) from the base section, hence it is immediately followed by another
326 <literal>.profile</literal> section that then introduces section @1. This profile overrides the kernel
327 command line. Finally, the last two sections define section @2, again overriding the command line. (Note
328 that in this example the first <literal>.cmdline</literal> could also moved behind the first
329 <literal>.profile</literal> with equivalent effect. To keep things nicely extensible, it's probably a
330 good idea to keep the generic command line in the base section instead of profile 0, in case later added
331 profiles might want to reuse it.)</para>
332
333 <para>The profile to boot may be controlled via the UKI's own command line: if the first argument starts
334 with <literal>@</literal>, followed by a positive integer number in decimal, it selects the profile to
335 boot into. If the first argument is not specified like that, the UKI will automatically boot into profile
336 0.</para>
337
338 <para>A <literal>.profile</literal> section may contain meta-information about the profile. It follows a
339 similar format as <literal>.osrel</literal> (i.e. an environment-variable-assignment-block-like list of
340 newline separated strings). Currently two fields are defined: <literal>ID=</literal> is supposed to carry
341 a short identifying string that identifies the profile
342 (e.g. <literal>ID=factory-reset</literal>). <literal>TITLE=</literal> should contain a human readable
343 string that may appear in the boot menu entry for this profile (e.g. <literal>TITLE='Factory Reset this
344 Device'</literal>).</para>
345 </refsect1>
346
347 <refsect1>
348 <title>TPM PCR Notes</title>
349
350 <para>Note that when a unified kernel using <command>systemd-stub</command> is invoked the firmware will
351 measure it as a whole to TPM PCR 4, covering all embedded resources, such as the stub code itself, the
352 core kernel, the embedded initrd and kernel command line (see above for a full list), including all UKI
353 profiles.</para>
354
355 <para>Also note that the Linux kernel will measure all initrds it receives into TPM PCR 9. This means
356 every type of initrd (of the selected UKI profile) will possibly be measured two or three times: the
357 initrds embedded in the kernel image will be measured to PCR 4, PCR 9 and PCR 11; the initrd synthesized
358 from credentials (and the one synthesized from configuration extensions) will be measured to both PCR 9
359 and PCR 12; the initrd synthesized from system extensions will be measured to both PCR 4 and PCR 9. Let's
360 summarize the OS resources and the PCRs they are measured to:</para>
361
362 <table>
363 <title>OS Resource PCR Summary</title>
364
365 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
366 <colspec colname="pcr" />
367 <colspec colname="definition" />
368
369 <thead>
370 <row>
371 <entry>OS Resource</entry>
372 <entry>Measurement PCR</entry>
373 </row>
374 </thead>
375
376 <tbody>
377 <row>
378 <entry><command>systemd-stub</command> code (the entry point of the unified PE binary)</entry>
379 <entry>4</entry>
380 </row>
381
382 <row>
383 <entry>Core kernel code (embedded in unified PE binary)</entry>
384 <entry>4 + 11</entry>
385 </row>
386
387 <row>
388 <entry>OS release information (embedded in the unified PE binary)</entry>
389 <entry>4 + 11</entry>
390 </row>
391
392 <row>
393 <entry>Main initrd (embedded in unified PE binary)</entry>
394 <entry>4 + 9 + 11</entry>
395 </row>
396
397 <row>
398 <entry>Microcode initrd (embedded in unified PE binary)</entry>
399 <entry>4 + 9 + 11</entry>
400 </row>
401
402 <row>
403 <entry>Default kernel command line (embedded in unified PE binary)</entry>
404 <entry>4 + 11</entry>
405 </row>
406
407 <row>
408 <entry>Overridden kernel command line</entry>
409 <entry>12</entry>
410 </row>
411
412 <row>
413 <entry>Boot splash (embedded in the unified PE binary)</entry>
414 <entry>4 + 11</entry>
415 </row>
416
417 <row>
418 <entry>TPM2 PCR signature JSON (embedded in unified PE binary, synthesized into initrd)</entry>
419 <entry>4 + 9</entry>
420 </row>
421
422 <row>
423 <entry>TPM2 PCR PEM public key (embedded in unified PE binary, synthesized into initrd)</entry>
424 <entry>4 + 9 + 11</entry>
425 </row>
426
427 <row>
428 <entry>Credentials (synthesized initrd from companion files)</entry>
429 <entry>9 + 12</entry>
430 </row>
431
432 <row>
433 <entry>System Extensions (synthesized initrd from companion files)</entry>
434 <entry>9 + 13</entry>
435 </row>
436
437 <row>
438 <entry>Configuration Extensions (synthesized initrd from companion files)</entry>
439 <entry>9 + 12</entry>
440 </row>
441
442 <row>
443 <entry>Selected profile unless zero</entry>
444 <entry>12</entry>
445 </row>
446 </tbody>
447 </tgroup>
448 </table>
449 </refsect1>
450
451 <refsect1>
452 <title>EFI Variables</title>
453
454 <para>The following EFI variables are defined, set and read by <command>systemd-stub</command>, under the
455 vendor UUID <literal>4a67b082-0a4c-41cf-b6c7-440b29bb8c4f</literal>, for communication between the boot
456 stub and the OS:</para>
457
458 <variablelist class='efi-variables'>
459 <varlistentry>
460 <term><varname>LoaderDevicePartUUID</varname></term>
461
462 <listitem><para>Contains the partition UUID of the partition the boot loader has been started from on
463 the current boot (usually a EFI System Partition). If already set by the boot loader, this will
464 remain untouched by <command>systemd-stub</command>. If not set yet, this will be set to the
465 partition UUID of the partition the unified kernel is started from, in order to support systems that
466 directly boot into a unified kernel image, bypassing any boot loader.
467 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
468 uses this information to automatically find the disk booted from, in order to discover various other
469 partitions on the same disk automatically.</para>
470
471 <xi:include href="version-info.xml" xpointer="v224"/></listitem>
472 </varlistentry>
473
474 <varlistentry>
475 <term><varname>LoaderFirmwareInfo</varname></term>
476 <term><varname>LoaderFirmwareType</varname></term>
477
478 <listitem><para>Brief firmware information. Use
479 <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view this
480 data.</para>
481
482 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
483 </varlistentry>
484
485 <varlistentry>
486 <term><varname>LoaderImageIdentifier</varname></term>
487
488 <listitem><para>The file system path to the EFI executable of the boot loader for the current boot,
489 relative to the partition's root directory (i.e. relative to the partition indicated by
490 <varname>LoaderDevicePartUUID</varname>, see above). If not set yet, this will be set to the file
491 system path of the EFI executable of the booted unified kernel, in order to support systems that
492 directly boot into a unified kernel image, bypassing any boot loader. Use
493 <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view
494 this data.</para>
495
496 <xi:include href="version-info.xml" xpointer="v237"/></listitem>
497 </varlistentry>
498
499 <varlistentry>
500 <term><varname>StubDevicePartUUID</varname></term>
501 <term><varname>StubImageIdentifier</varname></term>
502
503 <listitem><para>Similar to <varname>LoaderDevicePartUUID</varname> and
504 <varname>StubImageIdentifier</varname>, but indicates the location of the unified kernel image EFI
505 binary rather than the location of the boot loader binary, regardless if booted via a boot loader
506 or not.</para>
507
508 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
509 </varlistentry>
510
511 <varlistentry>
512 <term><varname>StubInfo</varname></term>
513
514 <listitem><para>Brief stub information. Use
515 <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view
516 this data.</para>
517
518 <xi:include href="version-info.xml" xpointer="v250"/></listitem>
519 </varlistentry>
520
521 <varlistentry>
522 <term><varname>StubPcrKernelImage</varname></term>
523
524 <listitem><para>The PCR register index the kernel image, initrd image, boot splash, devicetree
525 database, and the embedded command line are measured into, formatted as decimal ASCII string (e.g.
526 <literal>11</literal>). This variable is set if a measurement was successfully completed, and remains
527 unset otherwise.</para>
528
529 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
530 </varlistentry>
531
532 <varlistentry>
533 <term><varname>StubPcrKernelParameters</varname></term>
534
535 <listitem><para>The PCR register index the kernel command line and credentials are measured into,
536 formatted as decimal ASCII string (e.g. <literal>12</literal>). This variable is set if a measurement
537 was successfully completed, and remains unset otherwise.</para>
538
539 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
540 </varlistentry>
541
542 <varlistentry>
543 <term><varname>StubPcrInitRDSysExts</varname></term>
544
545 <listitem><para>The PCR register index the system extensions for the initrd, which are picked up from
546 the file system the kernel image is located on. Formatted as decimal ASCII string (e.g.
547 <literal>13</literal>). This variable is set if a measurement was successfully completed, and remains
548 unset otherwise.</para>
549
550 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
551 </varlistentry>
552
553 <varlistentry>
554 <term><varname>StubPcrInitRDConfExts</varname></term>
555
556 <listitem><para>The PCR register index the configuration extensions for the initrd, which are picked
557 up from the file system the kernel image is located on. Formatted as decimal ASCII string (e.g.
558 <literal>12</literal>). This variable is set if a measurement was successfully completed, and remains
559 unset otherwise.</para>
560
561 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
562 </varlistentry>
563
564 <varlistentry>
565 <term><varname>StubProfile</varname></term>
566
567 <listitem><para>The numeric index of the selected profile, without the <literal>@</literal>,
568 formatted as decimal string. Set both on single-profile and multi-profile UKIs. (In the former case
569 this variable will be set to <literal>0</literal> unconditionally.)</para>
570
571 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
572 </varlistentry>
573 </variablelist>
574
575 <para>Note that some of the variables above may also be set by the boot loader. The stub will only set
576 them if they aren't set already. Some of these variables are defined by the <ulink
577 url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink>.</para>
578 </refsect1>
579
580 <refsect1>
581 <title>initrd Resources</title>
582
583 <para>The following resources are passed as initrd cpio archives to the booted kernel, and thus make up
584 the initial file system hierarchy in the initrd execution environment:</para>
585
586 <variablelist>
587 <varlistentry>
588 <term><filename>/</filename></term>
589
590 <listitem><para>The main initrd from the <literal>.initrd</literal> PE section of the unified kernel
591 image.</para>
592
593 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
594 </varlistentry>
595
596 <varlistentry>
597 <term><filename>/.extra/credentials/*.cred</filename></term>
598 <listitem><para>Credential files (suffix <literal>.cred</literal>) that are placed next to the
599 unified kernel image (as described above) are copied into the
600 <filename>/.extra/credentials/</filename> directory in the initrd execution
601 environment.</para>
602
603 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
604 </varlistentry>
605
606 <varlistentry>
607 <term><filename>/.extra/global_credentials/*.cred</filename></term>
608 <listitem><para>Similarly, credential files in the <filename>/loader/credentials/</filename>
609 directory in the file system the unified kernel image is placed in are copied into the
610 <filename>/.extra/global_credentials/</filename> directory in the initrd execution
611 environment.</para>
612
613 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
614 </varlistentry>
615
616 <varlistentry>
617 <term><filename>/.extra/sysext/*.sysext.raw</filename></term>
618 <listitem><para>System extension image files (suffix <literal>.sysext.raw</literal>) that are placed
619 next to the unified kernel image (as described above) are copied into the
620 <filename>/.extra/sysext/</filename> directory in the initrd execution environment.</para>
621
622 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
623 </varlistentry>
624
625 <varlistentry>
626 <term><filename>/.extra/confext/*.confext.raw</filename></term>
627 <listitem><para>Configuration extension image files (suffix <literal>.confext.raw</literal>) that are
628 placed next to the unified kernel image (as described above) are copied into the
629 <filename>/.extra/confext/</filename> directory in the initrd execution environment.</para>
630
631 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
632 </varlistentry>
633
634 <varlistentry>
635 <term><filename>/.extra/tpm2-pcr-signature.json</filename></term>
636 <listitem><para>The TPM2 PCR signature JSON object included in the <literal>.pcrsig</literal> PE
637 section of the unified kernel image is copied into the
638 <filename>/.extra/tpm2-pcr-signature.json</filename> file in the initrd execution environment.</para>
639
640 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
641 </varlistentry>
642
643 <varlistentry>
644 <term><filename>/.extra/tpm2-pcr-public-key.pem</filename></term>
645 <listitem><para>The PEM public key included in the <literal>.pcrpkey</literal> PE section of the
646 unified kernel image is copied into the <filename>/.extra/tpm2-pcr-public-key.pem</filename> file in
647 the initrd execution environment.</para>
648
649 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
650 </varlistentry>
651
652 <varlistentry>
653 <term><filename>/.extra/profile</filename></term>
654 <term><filename>/.extra/os-release</filename></term>
655 <listitem><para>The contents of the <literal>.profile</literal> and <literal>.osrel</literal>
656 sections of the selected profile, if any.</para>
657
658 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
659 </varlistentry>
660 </variablelist>
661
662 <para>Note that all these files are located in the <literal>tmpfs</literal> file system the kernel sets
663 up for the initrd file hierarchy and are thus lost when the system transitions from the initrd execution
664 environment into the host file system. If these resources shall be kept around over this transition they
665 need to be copied to a place that survives the transition first, for example via a suitable
666 <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line. By
667 default, this is done for the TPM2 PCR signature and public key files.</para>
668 </refsect1>
669
670 <refsect1>
671 <title>SMBIOS Type 11 Strings</title>
672
673 <para><command>systemd-stub</command> can be configured using SMBIOS Type 11 strings. Applicable strings
674 consist of a name, followed by <literal>=</literal>, followed by the value. Unless
675 <command>systemd-stub</command> detects it is running inside a confidential computing environment,
676 <command>systemd-stub</command> will search the table for a string with a specific name, and if found,
677 use its value. The following strings are read:</para>
678
679 <variablelist>
680 <varlistentry>
681 <term><varname>io.systemd.stub.kernel-cmdline-extra</varname></term>
682 <listitem><para>If set, the value of this string is added to the list of kernel command line
683 arguments that are measured in PCR12 and passed to the kernel.</para>
684
685 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
686 </varlistentry>
687 </variablelist>
688 </refsect1>
689
690 <refsect1>
691 <title>Assembling Kernel Images</title>
692
693 <para>In order to assemble a bootable Unified Kernel Image from various components as described above, use
694 <citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
695 </refsect1>
696
697 <refsect1>
698 <title>See Also</title>
699 <para><simplelist type="inline">
700 <member><citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
701 <member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
702 <member><citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
703 <member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
704 <member><ulink url="https://uapi-group.org/specifications/specs/boot_loader_specification">Boot Loader Specification</ulink></member>
705 <member><ulink url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink></member>
706 <member><citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
707 <member><citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
708 <member><ulink url="https://systemd.io/TPM2_PCR_MEASUREMENTS">TPM2 PCR Measurements Made by systemd</ulink></member>
709 </simplelist></para>
710 </refsect1>
711 </refentry>