]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd-sysext.xml
8227b972b9af0b77b272bd70fe3a20e704e4b117
[thirdparty/systemd.git] / man / systemd-sysext.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.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-sysext"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>systemd-sysext</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd-sysext</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd-sysext</refname>
21 <refname>systemd-sysext.service</refname>
22 <refname>systemd-confext</refname>
23 <refname>systemd-confext.service</refname>
24 <refpurpose>Activates System Extension Images</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <cmdsynopsis>
29 <command>systemd-sysext</command>
30 <arg choice="opt" rep="repeat">OPTIONS</arg>
31 <arg choice="plain">COMMAND</arg>
32 </cmdsynopsis>
33
34 <para><literallayout><filename>systemd-sysext.service</filename></literallayout></para>
35
36 <cmdsynopsis>
37 <command>systemd-confext</command>
38 <arg choice="opt" rep="repeat">OPTIONS</arg>
39 <arg choice="plain">COMMAND</arg>
40 </cmdsynopsis>
41
42 <para><literallayout><filename>systemd-confext.service</filename></literallayout></para>
43
44 </refsynopsisdiv>
45
46 <refsect1>
47 <title>Description</title>
48
49 <para><command>systemd-sysext</command> activates/deactivates system extension images. System extension
50 images may – dynamically at runtime — extend the <filename>/usr/</filename> and
51 <filename>/opt/</filename> directory hierarchies with additional files. This is particularly useful on
52 immutable system images where a <filename>/usr/</filename> and/or <filename>/opt/</filename> hierarchy
53 residing on a read-only file system shall be extended temporarily at runtime without making any
54 persistent modifications.</para>
55
56 <para>System extension images should contain files and directories similar in fashion to regular
57 operating system tree. When one or more system extension images are activated, their
58 <filename>/usr/</filename> and <filename>/opt/</filename> hierarchies are combined via
59 <literal>overlayfs</literal> with the same hierarchies of the host OS, and the host
60 <filename>/usr/</filename> and <filename>/opt/</filename> overmounted with it ("merging"). When they are
61 deactivated, the mount point is disassembled — again revealing the unmodified original host version of
62 the hierarchy ("unmerging"). Merging thus makes the extension's resources suddenly appear below the
63 <filename>/usr/</filename> and <filename>/opt/</filename> hierarchies as if they were included in the
64 base OS image itself. Unmerging makes them disappear again, leaving in place only the files that were
65 shipped with the base OS image itself.</para>
66
67 <para>Files and directories contained in the extension images outside of the <filename>/usr/</filename>
68 and <filename>/opt/</filename> hierarchies are <emphasis>not</emphasis> merged, and hence have no effect
69 when included in a system extension image. In particular, files in the <filename>/etc/</filename> and
70 <filename>/var/</filename> included in a system extension image will <emphasis>not</emphasis> appear in
71 the respective hierarchies after activation.</para>
72
73 <para>System extension images are strictly read-only, and the host <filename>/usr/</filename> and
74 <filename>/opt/</filename> hierarchies become read-only too while they are activated.</para>
75
76 <para>System extensions are supposed to be purely additive, i.e. they are supposed to include only files
77 that do not exist in the underlying basic OS image. However, the underlying mechanism (overlayfs) also
78 allows overlaying or removing files, but it is recommended not to make use of this.</para>
79
80 <para>System extension images may be provided in the following formats:</para>
81
82 <orderedlist>
83 <listitem><para>Plain directories or btrfs subvolumes containing the OS tree</para></listitem>
84 <listitem><para>Disk images with a GPT disk label, following the <ulink
85 url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">Discoverable Partitions Specification</ulink></para></listitem>
86 <listitem><para>Disk images lacking a partition table, with a naked Linux file system (e.g. erofs,
87 squashfs or ext4)</para></listitem>
88 </orderedlist>
89
90 <para>These image formats are the same ones that
91 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
92 supports via its <option>--directory=</option>/<option>--image=</option> switches and those that the
93 service manager supports via <option>RootDirectory=</option>/<option>RootImage=</option>. Similar to
94 them they may optionally carry Verity authentication information.</para>
95
96 <para>System extensions are searched for in the directories
97 <filename>/etc/extensions/</filename>, <filename>/run/extensions/</filename> and
98 <filename>/var/lib/extensions/</filename>. The first two listed directories are not suitable for
99 carrying large binary images, however are still useful for carrying symlinks to them. The primary place
100 for installing system extensions is <filename>/var/lib/extensions/</filename>. Any directories found in
101 these search directories are considered directory based extension images; any files with the
102 <filename>.raw</filename> suffix are considered disk image based extension images. When invoked in the
103 initrd, the additional directory <filename>/.extra/sysext/</filename> is included in the directories that
104 are searched for extension images. Note however, that by default a tighter image policy applies to images
105 found there, though, see below. This directory is populated by
106 <citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry> with
107 extension images found in the system's EFI System Partition.</para>
108
109 <para>During boot OS extension images are activated automatically, if the
110 <filename>systemd-sysext.service</filename> is enabled. Note that this service runs only after the
111 underlying file systems where system extensions may be located have been mounted. This means they are not
112 suitable for shipping resources that are processed by subsystems running in earliest boot. Specifically,
113 OS extension images are not suitable for shipping system services or
114 <citerefentry><refentrytitle>systemd-sysusers</refentrytitle><manvolnum>8</manvolnum></citerefentry>
115 definitions. See the <ulink url="https://systemd.io/PORTABLE_SERVICES">Portable Services Documentation</ulink>
116 for a simple mechanism for shipping system services in disk images, in a similar fashion to OS
117 extensions. Note the different isolation on these two mechanisms: while system extension directly extend
118 the underlying OS image with additional files that appear in a way very similar to as if they were
119 shipped in the OS image itself and thus imply no security isolation, portable services imply service
120 level sandboxing in one way or another. The <filename>systemd-sysext.service</filename> service is
121 guaranteed to finish start-up before <filename>basic.target</filename> is reached; i.e. at the time
122 regular services initialize (those which do not use <varname>DefaultDependencies=no</varname>), the files
123 and directories system extensions provide are available in <filename>/usr/</filename> and
124 <filename>/opt/</filename> and may be accessed.</para>
125
126 <para>Note that there is no concept of enabling/disabling installed system extension images: all
127 installed extension images are automatically activated at boot. However, you can place an empty directory
128 named like the extension (no <filename>.raw</filename>) in <filename>/etc/extensions/</filename> to "mask"
129 an extension with the same name in a system folder with lower precedence.</para>
130
131 <para>A simple mechanism for version compatibility is enforced: a system extension image must carry a
132 <filename>/usr/lib/extension-release.d/extension-release.<replaceable>$name</replaceable></filename>
133 file, which must match its image name, that is compared with the host <filename>os-release</filename>
134 file: the contained <varname>ID=</varname> fields have to match unless <literal>_any</literal> is set
135 for the extension. If the extension <varname>ID=</varname> is not <literal>_any</literal>, the
136 <varname>SYSEXT_LEVEL=</varname> field (if defined) has to match. If the latter is not defined, the
137 <varname>VERSION_ID=</varname> field has to match instead. If the extension defines the
138 <varname>ARCHITECTURE=</varname> field and the value is not <literal>_any</literal> it has to match the kernel's
139 architecture reported by <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry>
140 but the used architecture identifiers are the same as for <varname>ConditionArchitecture=</varname>
141 described in <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
142 <varname>EXTENSION_RELOAD_MANAGER=</varname> can be set to 1 if the extension requires a service manager reload after application
143 of the extension. Note that the for the reasons mentioned earlier:
144 <ulink url="https://systemd.io/PORTABLE_SERVICES">Portable Services</ulink> remain
145 the recommended way to ship system services.
146
147 System extensions should not ship a <filename>/usr/lib/os-release</filename> file (as that would be merged
148 into the host <filename>/usr/</filename> tree, overriding the host OS version data, which is not desirable).
149 The <filename>extension-release</filename> file follows the same format and semantics, and carries the same
150 content, as the <filename>os-release</filename> file of the OS, but it describes the resources carried
151 in the extension image.</para>
152
153 <para>The <command>systemd-confext</command> concept follows the same principle as the
154 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>1</manvolnum></citerefentry>
155 functionality but instead of working on <filename>/usr</filename> and <filename>/opt</filename>,
156 <command>confext</command> will extend only <filename>/etc</filename>. Files and directories contained
157 in the confext images outside of the <filename>/etc/</filename> hierarchy are <emphasis>not</emphasis>
158 merged, and hence have no effect when included in the image. Formats for these images are of the
159 same as sysext images. The merged hierarchy will be mounted with <literal>nosuid</literal> and
160 (if not disabled via <option>--noexec=false</option>) <literal>noexec</literal>.</para>
161
162 <para>Confexts are looked for in the directories <filename>/run/confexts/</filename>,
163 <filename>/var/lib/confexts/</filename>, <filename>/usr/lib/confexts/</filename> and
164 <filename>/usr/local/lib/confexts/</filename>. The first listed directory is not suitable for
165 carrying large binary images, however is still useful for carrying symlinks to them. The primary place
166 for installing configuration extensions is <filename>/var/lib/confexts/</filename>. Any directories found
167 in these search directories are considered directory based confext images; any files with the
168 <filename>.raw</filename> suffix are considered disk image based confext images.</para>
169
170 <para>Again, just like sysext images, the confext images will contain a
171 <filename>/etc/extension-release.d/extension-release.<replaceable>$name</replaceable></filename>
172 file, which must match the image name (with the usual escape hatch of xattr), and again with content
173 being one or more of <varname>ID=</varname>, <varname>VERSION_ID=</varname>, and
174 <varname>CONFEXT_LEVEL</varname>. Confext images will then be checked and matched against the
175 base OS layer.</para>
176 </refsect1>
177
178 <refsect1>
179 <title>Uses</title>
180
181 <para>The primary use case for system images are immutable environments where debugging and development
182 tools shall optionally be made available, but not included in the immutable base OS image itself (e.g.
183 <citerefentry project='man-pages'><refentrytitle>strace</refentrytitle><manvolnum>1</manvolnum></citerefentry>
184 and
185 <citerefentry project='man-pages'><refentrytitle>gdb</refentrytitle><manvolnum>1</manvolnum></citerefentry>
186 shall be an optionally installable addition in order to make debugging/development easier). System
187 extension images should not be misunderstood as a generic software packaging framework, as no dependency
188 scheme is available: system extensions should carry all files they need themselves, except for those
189 already shipped in the underlying host system image. Typically, system extension images are built at the
190 same time as the base OS image — within the same build system.</para>
191
192 <para>Another use case for the system extension concept is temporarily overriding OS supplied resources
193 with newer ones, for example to install a locally compiled development version of some low-level
194 component over the immutable OS image without doing a full OS rebuild or modifying the nominally
195 immutable image. (e.g. "install" a locally built package with <command>DESTDIR=/var/lib/extensions/mytest
196 make install &amp;&amp; systemd-sysext refresh</command>, making it available in
197 <filename>/usr/</filename> as if it was installed in the OS image itself.) This case works regardless if
198 the underlying host <filename>/usr/</filename> is managed as immutable disk image or is a traditional
199 package manager controlled (i.e. writable) tree.</para>
200
201 <para>For the confext case, the OSConfig project aims to perform runtime reconfiguration of OS services.
202 Sometimes, there is a need to swap certain configuration parameter values or restart only a specific
203 service without deployment of new code or a complete OS deployment. In other words, we want to be able
204 to tie the most frequently configured options to runtime updateable flags that can be changed without a
205 system reboot. This will help reduce servicing times when there is a need for changing the OS configuration.</para></refsect1>
206
207 <refsect1>
208 <title>Commands</title>
209
210 <para>The following commands are understood by both the sysext and confext concepts:</para>
211
212 <variablelist>
213 <varlistentry>
214 <term><option>status</option></term>
215
216 <listitem><para>When invoked without any command verb, or when <option>status</option> is specified
217 the current merge status is shown, separately (for both <filename>/usr/</filename> and
218 <filename>/opt/</filename> of sysext and for <filename>/etc/</filename> of confext).</para>
219
220 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
221 </varlistentry>
222
223 <varlistentry>
224 <term><option>merge</option></term>
225 <listitem><para>Merges all currently installed system extension images into
226 <filename>/usr/</filename> and <filename>/opt/</filename>, by overmounting these hierarchies with an
227 <literal>overlayfs</literal> file system combining the underlying hierarchies with those included in
228 the extension images. This command will fail if the hierarchies are already merged. For confext, the merge
229 happens into the <filename>/etc/</filename> directory instead.</para>
230
231 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
232 </varlistentry>
233
234 <varlistentry>
235 <term><option>unmerge</option></term>
236 <listitem><para>Unmerges all currently installed system extension images from
237 <filename>/usr/</filename> and <filename>/opt/</filename> for sysext and <filename>/etc/</filename>,
238 for confext, by unmounting the <literal>overlayfs</literal> file systems created by <option>merge</option>
239 prior.</para>
240
241 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
242 </varlistentry>
243
244 <varlistentry>
245 <term><option>refresh</option></term>
246 <listitem><para>A combination of <option>unmerge</option> and <option>merge</option>: if already
247 mounted the existing <literal>overlayfs</literal> instance is unmounted temporarily, and then
248 replaced by a new version. This command is useful after installing/removing system extension images,
249 in order to update the <literal>overlayfs</literal> file system accordingly. If no system extensions
250 are installed when this command is executed, the equivalent of <option>unmerge</option> is executed,
251 without establishing any new <literal>overlayfs</literal> instance.
252 Note that currently there's a brief moment where neither the old nor the new <literal>overlayfs</literal>
253 file system is mounted. This implies that all resources supplied by a system extension will briefly
254 disappear — even if it exists continuously during the refresh operation.</para>
255
256 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
257 </varlistentry>
258
259 <varlistentry>
260 <term><option>list</option></term>
261
262 <listitem><para>A brief list of installed extension images is shown.</para>
263
264 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
265 </varlistentry>
266
267 <xi:include href="standard-options.xml" xpointer="help" />
268 <xi:include href="standard-options.xml" xpointer="version" />
269 </variablelist>
270 </refsect1>
271
272 <refsect1>
273 <title>Options</title>
274
275 <variablelist>
276 <varlistentry>
277 <term><option>--root=</option></term>
278
279 <listitem><para>Operate relative to the specified root directory, i.e. establish the
280 <literal>overlayfs</literal> mount not on the top-level host <filename>/usr/</filename> and
281 <filename>/opt/</filename> hierarchies for sysext or <filename>/etc/</filename> for confext,
282 but below some specified root directory.</para>
283
284 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
285 </varlistentry>
286
287 <varlistentry>
288 <term><option>--force</option></term>
289
290 <listitem><para>When merging system extensions into <filename>/usr/</filename> and
291 <filename>/opt/</filename> for sysext and <filename>/etc/</filename> for confext,
292 ignore version incompatibilities, i.e. force merging regardless of
293 whether the version information included in the images matches the host or not.</para>
294
295 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
296 </varlistentry>
297
298 <varlistentry>
299 <term><option>--image-policy=<replaceable>policy</replaceable></option></term>
300
301 <listitem><para>Takes an image policy string as argument, as per
302 <citerefentry><refentrytitle>systemd.image-policy</refentrytitle><manvolnum>7</manvolnum></citerefentry>. The
303 policy is enforced when operating on system extension disk images. If not specified defaults to
304 <literal>root=verity+signed+encrypted+unprotected+absent:usr=verity+signed+encrypted+unprotected+absent</literal>
305 for system extensions, i.e. only the root and <filename>/usr/</filename> file systems in the image
306 are used. For configuration extensions defaults to
307 <literal>root=verity+signed+encrypted+unprotected+absent</literal>. When run in the initrd and
308 operating on a system extension image stored in the <filename>/.extra/sysext/</filename> directory a
309 slightly stricter policy is used by default: <literal>root=signed+absent:usr=signed+absent</literal>,
310 see above for details.</para>
311
312 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
313 </varlistentry>
314
315 <varlistentry>
316 <term><option>--noexec=</option><replaceable>BOOL</replaceable></term>
317
318 <listitem><para>When merging configuration extensions into <filename>/etc/</filename> the
319 <literal>MS_NOEXEC</literal> mount flag is used by default. This option can be used to disable
320 it.</para>
321
322 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
323 </varlistentry>
324
325 <varlistentry>
326 <term><option>--no-reload</option></term>
327
328 <listitem>
329 <para>When used with <command>merge</command>,
330 <command>unmerge</command> or <command>refresh</command>, do not reload daemon
331 after executing the changes even if an extension that is applied requires a reload via the
332 <varname>EXTENSION_RELOAD_MANAGER=</varname> set to 1.</para>
333
334 <xi:include href="version-info.xml" xpointer="v255"/>
335 </listitem>
336 </varlistentry>
337
338 <xi:include href="standard-options.xml" xpointer="no-pager" />
339 <xi:include href="standard-options.xml" xpointer="no-legend" />
340 <xi:include href="standard-options.xml" xpointer="json" />
341 </variablelist>
342 </refsect1>
343
344 <refsect1>
345 <title>Exit status</title>
346
347 <para>On success, 0 is returned.</para>
348 </refsect1>
349
350 <refsect1>
351 <title>See Also</title>
352 <para>
353 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
354 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
355 <citerefentry><refentrytitle>systemd-stub</refentrytitle><manvolnum>7</manvolnum></citerefentry>
356 </para>
357 </refsect1>
358
359 </refentry>