]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/portablectl.xml
Merge pull request #18863 from keszybz/cmdline-escaping
[thirdparty/systemd.git] / man / portablectl.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
a8c42bb8 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
db9ecf05 4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
a8c42bb8
LP
5
6<refentry id="portablectl" conditional='ENABLE_PORTABLED'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>portablectl</title>
11 <productname>systemd</productname>
a8c42bb8
LP
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>portablectl</refentrytitle>
16 <manvolnum>1</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>portablectl</refname>
21 <refpurpose>Attach, detach or inspect portable service images</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <cmdsynopsis>
26 <command>portablectl</command>
27 <arg choice="opt" rep="repeat">OPTIONS</arg>
28 <arg choice="req">COMMAND</arg>
29 <arg choice="opt" rep="repeat">NAME</arg>
30 </cmdsynopsis>
31 </refsynopsisdiv>
32
33 <refsect1>
34 <title>Description</title>
35
36 <para><command>portablectl</command> may be used to attach, detach or inspect portable service images. It's
37 primarily a command interfacing with
38 <citerefentry><refentrytitle>systemd-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
39
40 <para>Portable service images contain an OS file system tree along with
41 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> unit file
42 information. A service image may be "attached" to the local system. If attached, a set of unit files are copied
43 from the image to the host, and extended with <varname>RootDirectory=</varname> or <varname>RootImage=</varname>
44 assignments (in case of service units) pointing to the image file or directory, ensuring the services will run
45 within the file system context of the image.</para>
46
47 <para>Portable service images are an efficient way to bundle multiple related services and other units together,
48 and transfer them as a whole between systems. When these images are attached the local system the contained units
49 may run in most ways like regular system-provided units, either with full privileges or inside strict sandboxing,
50 depending on the selected configuration.</para>
51
52 <para>Specifically portable service images may be of the following kind:</para>
53
54 <itemizedlist>
55 <listitem><para>Directory trees containing an OS, including the top-level directories <filename>/usr/</filename>,
56 <filename>/etc/</filename>, and so on.</para></listitem>
57
58 <listitem><para>btrfs subvolumes containing OS trees, similar to normal directory trees.</para></listitem>
59
60 <listitem><para>Binary "raw" disk images containing MBR or GPT partition tables and Linux file system
787dfb82 61 partitions. (These must be regular files, with the <filename>.raw</filename> suffix.)</para></listitem>
a8c42bb8
LP
62 </itemizedlist>
63
64 </refsect1>
65
a8c42bb8
LP
66 <refsect1>
67 <title>Commands</title>
68
69 <para>The following commands are understood:</para>
70
71 <variablelist>
72
73 <varlistentry>
74 <term><command>list</command></term>
75
76 <listitem><para>List available portable service images. This will list all portable service images discovered
77 in the portable image search paths (see below), along with brief metadata and state information. Note that many
78 of the commands below may both operate on images inside and outside of the search paths. This command is hence
79 mostly a convenience option, the commands are generally not restricted to what this list
80 shows.</para></listitem>
81 </varlistentry>
82
83 <varlistentry>
84 <term><command>attach</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
85
86 <listitem><para>Attach a portable service image to the host system. Expects a file system path to a portable
87 service image file or directory as first argument. If the specified path contains no slash character
88 (<literal>/</literal>) it is understood as image filename that is searched for in the portable service image
89 search paths (see below). To reference a file in the current working directory prefix the filename with
90 <literal>./</literal> to avoid this search path logic.</para>
91
92 <para>When a portable service is attached four operations are executed:</para>
93
94 <orderedlist>
95
96 <listitem><para>All unit files of types <filename>.service</filename>, <filename>.socket</filename>,
97 <filename>.target</filename>, <filename>.timer</filename> and <filename>.path</filename> which match the
98 indicated unit file name prefix are copied from the image to the host's
83f72cd6
LP
99 <filename>/etc/systemd/system.attached/</filename> directory (or
100 <filename>/run/systemd/system.attached/</filename> — depending whether <option>--runtime</option> is
101 specified, see above), which is included in the built-in unit search path of the system service
102 manager.</para></listitem>
a8c42bb8
LP
103
104 <listitem><para>For unit files of type <filename>.service</filename> a drop-in is added to these copies that
105 adds <varname>RootDirectory=</varname> or <varname>RootImage=</varname> settings (see
106 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
107 details), that ensures these services are run within the file system of the originating portable service
108 image.</para></listitem>
109
110 <listitem><para>A second drop-in is created: the "profile" drop-in, that may contain additional security
111 settings (and other settings). A number of profiles are available by default but administrators may define
112 their own ones. See below.</para></listitem>
113
114 <listitem><para>If the portable service image file is not already in the search path (see below), a symbolic
115 link to it is created in <filename>/etc/portables/</filename> or
116 <filename>/run/portables/</filename>, to make sure it is included in it.</para></listitem>
117 </orderedlist>
118
119 <para>By default all unit files whose names start with a prefix generated from the image's file name are copied
120 out. Specifically, the prefix is determined from the image file name with any suffix such as
e9dd6984 121 <filename>.raw</filename> removed, truncated at the first occurrence of an underscore character
a8c42bb8
LP
122 (<literal>_</literal>), if there is one. The underscore logic is supposed to be used to versioning so that the
123 an image file <filename>foobar_47.11.raw</filename> will result in a unit file matching prefix of
124 <filename>foobar</filename>. This prefix is then compared with all unit files names contained in the image in
125 the usual directories, but only unit file names where the prefix is followed by <literal>-</literal>,
126 <literal>.</literal> or <literal>@</literal> are considered. Example: if a portable service image file is named
127 <filename>foobar_47.11.raw</filename> then by default all its unit files with names such as
128 <filename>foobar-quux-waldi.service</filename>, <filename>foobar.service</filename> or
129 <filename>foobar@.service</filename> will be considered. It's possible to override the matching prefix: all
130 strings listed on the command line after the image file name are considered prefixes, overriding the implicit
131 logic where the prefix is derived from the image file name.</para>
132
133 <para>By default, after the unit files are attached the service manager's configuration is reloaded, except
134 when <option>--no-reload</option> is specified (see above). This ensures that the new units made available to
135 the service manager are seen by it.</para>
e2c1ddcc
LB
136
137 <para>If <option>--now</option> and/or <option>--enable</option> are passed, the portable service(s) are
31c33315
LB
138 immediately started (blocking operation unless <option>--no-block</option> is passed) and/or enabled after
139 attaching the image.</para>
a8c42bb8
LP
140 </listitem>
141 </varlistentry>
142
143 <varlistentry>
e2c1ddcc 144 <term><command>detach</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
a8c42bb8
LP
145
146 <listitem><para>Detaches a portable service image from the host. This undoes the operations executed by the
147 <command>attach</command> command above, and removes the unit file copies, drop-ins and image symlink
148 again. This command expects an image name or path as parameter. Note that if a path is specified only the last
149 component of it (i.e. the file or directory name itself, not the path to it) is used for finding matching unit
5e2b0e1c 150 files. This is a convenience feature to allow all arguments passed as <command>attach</command> also to
a8c42bb8 151 <command>detach</command>.</para></listitem>
e2c1ddcc
LB
152
153 <para>If <option>--now</option> and/or <option>--enable</option> are passed, the portable service(s) are
31c33315
LB
154 immediately stopped (blocking operation) and/or disabled before detaching the image. Prefix(es) are also accepted,
155 to be used in case the unit names do not match the image name as described in the <command>attach</command>.</para>
a8c42bb8
LP
156 </varlistentry>
157
e26fe5f9
LB
158 <varlistentry>
159 <term><command>reattach</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
160
161 <listitem><para>Detaches an existing portable service image from the host, and immediately attaches it again.
162 This is useful in case the image was replaced. Running units are not stopped during the process. Partial matching,
163 to allow for different versions in the image name, is allowed: only the part before the first <literal>_</literal>
164 character has to match. If the new image doesn't exist, the existing one will not be detached. The parameters
165 follow the same syntax as the <command>attach</command> command.</para></listitem>
166
167 <para>If <option>--now</option> and/or <option>--enable</option> are passed, the portable service(s) are
168 immediately stopped if removed, started and/or enabled if added, or restarted if updated. Prefixes are also
169 accepted, in the same way as described in the <command>attach</command> case.</para>
170 </varlistentry>
171
a8c42bb8
LP
172 <varlistentry>
173 <term><command>inspect</command> <replaceable>IMAGE</replaceable> [<replaceable>PREFIX…</replaceable>]</term>
174
175 <listitem><para>Extracts various metadata from a portable service image and presents it to the
176 caller. Specifically, the
177 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file of the
178 image is retrieved as well as all matching unit files. By default a short summary showing the most relevant
179 metadata in combination with a list of matching unit files is shown (that is the unit files
180 <command>attach</command> would install to the host system). If combined with <option>--cat</option> (see
181 above), the <filename>os-release</filename> data and the units files' contents is displayed unprocessed. This
182 command is useful to determine whether an image qualifies as portable service image, and which unit files are
183 included. This command expects the path to the image as parameter, optionally followed by a list of unit file
184 prefixes to consider, similar to the <command>attach</command> command described above.</para>
185 </listitem>
186 </varlistentry>
187
188 <varlistentry>
189 <term><command>is-attached</command> <replaceable>IMAGE</replaceable></term>
190
191 <listitem><para>Determines whether the specified image is currently attached or not. Unless combined with the
192 <option>--quiet</option> switch this will show a short state identifier for the image. Specifically:</para>
193
194 <table>
195 <title>Image attachment states</title>
196 <tgroup cols='2'>
197 <colspec colname='state'/>
198 <colspec colname='description'/>
199 <thead>
200 <row>
201 <entry>State</entry>
202 <entry>Description</entry>
203 </row>
204 </thead>
205 <tbody>
206 <row>
207 <entry><option>detached</option></entry>
208 <entry>The image is currently not attached.</entry>
209 </row>
210 <row>
211 <entry><option>attached</option></entry>
212 <entry>The image is currently attached, i.e. its unit files have been made available to the host system.</entry>
213 </row>
214 <row>
215 <entry><option>attached-runtime</option></entry>
1b2ad5d9 216 <entry>Like <option>attached</option>, but the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
a8c42bb8
LP
217 </row>
218 <row>
219 <entry><option>enabled</option></entry>
220 <entry>The image is currently attached, and at least one unit file associated with it has been enabled.</entry>
221 </row>
222 <row>
223 <entry><option>enabled-runtime</option></entry>
f32d15b0 224 <entry>Like <option>enabled</option>, but the unit files have been made available transiently only, i.e. the <command>attach</command> command has been invoked with the <option>--runtime</option> option.</entry>
a8c42bb8
LP
225 </row>
226 <row>
227 <entry><option>running</option></entry>
228 <entry>The image is currently attached, and at least one unit file associated with it is running.</entry>
229 </row>
230 <row>
231 <entry><option>running-runtime</option></entry>
232 <entry>The image is currently attached transiently, and at least one unit file associated with it is running.</entry>
233 </row>
234 </tbody>
235 </tgroup>
236 </table>
237
238 </listitem>
239 </varlistentry>
240
241 <varlistentry>
242 <term><command>read-only</command> <replaceable>IMAGE</replaceable> [<replaceable>BOOL</replaceable>]</term>
243
244 <listitem><para>Marks or (unmarks) a portable service image read-only. Takes an image name, followed by a
245 boolean as arguments. If the boolean is omitted, positive is implied, i.e. the image is marked
246 read-only.</para></listitem>
247 </varlistentry>
248
249 <varlistentry>
250 <term><command>remove</command> <replaceable>IMAGE</replaceable>…</term>
251
252 <listitem><para>Removes one or more portable service images. Note that this command will only remove the
1b2ad5d9 253 specified image path itself — it refers to a symbolic link then the symbolic link is removed and not the
a8c42bb8
LP
254 image it points to.</para></listitem>
255 </varlistentry>
256
257 <varlistentry>
c2b67dc6 258 <term><command>set-limit</command> [<replaceable>IMAGE</replaceable>] <replaceable>BYTES</replaceable></term>
a8c42bb8
LP
259
260 <listitem><para>Sets the maximum size in bytes that a specific portable service image, or all images, may grow
261 up to on disk (disk quota). Takes either one or two parameters. The first, optional parameter refers to a
262 portable service image name. If specified, the size limit of the specified image is changed. If omitted, the
263 overall size limit of the sum of all images stored locally is changed. The final argument specifies the size
264 limit in bytes, possibly suffixed by the usual K, M, G, T units. If the size limit shall be disabled, specify
265 <literal>-</literal> as size.</para>
266
267 <para>Note that per-image size limits are only supported on btrfs file systems. Also, depending on
268 <varname>BindPaths=</varname> settings in the portable service's unit files directories from the host might be
269 visible in the image environment during runtime which are not affected by this setting, as only the image
270 itself is counted against this limit.</para></listitem>
271 </varlistentry>
272
273 </variablelist>
274
275 </refsect1>
276
e1fac8a6
ZJS
277 <refsect1>
278 <title>Options</title>
279
280 <para>The following options are understood:</para>
281
282 <variablelist>
283 <varlistentry>
284 <term><option>-q</option></term>
285 <term><option>--quiet</option></term>
286
287 <listitem><para>Suppresses additional informational output while running.</para></listitem>
288 </varlistentry>
289
290 <varlistentry>
291 <term><option>-p</option> <replaceable>PROFILE</replaceable></term>
292 <term><option>--profile=</option><replaceable>PROFILE</replaceable></term>
293
294 <listitem><para>When attaching an image, select the profile to use. By default the <literal>default</literal>
295 profile is used. For details about profiles, see below.</para></listitem>
296 </varlistentry>
297
298 <varlistentry>
299 <term><option>--copy=</option></term>
300
301 <listitem><para>When attaching an image, select whether to prefer copying or symlinking of files installed into
302 the host system. Takes one of <literal>copy</literal> (to prefer copying of files), <literal>symlink</literal>
303 (to prefer creation of symbolic links) or <literal>auto</literal> for an intermediary mode where security
304 profile drop-ins are symlinked while unit files are copied. Note that this option expresses a preference only,
305 in cases where symbolic links cannot be created — for example when the image operated on is a raw disk image,
306 and hence not directly referentiable from the host file system — copying of files is used
307 unconditionally.</para></listitem>
308 </varlistentry>
309
310 <varlistentry>
311 <term><option>--runtime</option></term>
312
313 <listitem><para>When specified the unit and drop-in files are placed in
314 <filename>/run/systemd/system.attached/</filename> instead of
315 <filename>/etc/systemd/system.attached/</filename>. Images attached with this option set hence remain attached
316 only until the next reboot, while they are normally attached persistently.</para></listitem>
317 </varlistentry>
318
319 <varlistentry>
320 <term><option>--no-reload</option></term>
321
322 <listitem><para>Don't reload the service manager after attaching or detaching a portable service
323 image. Normally the service manager is reloaded to ensure it is aware of added or removed unit
324 files.</para></listitem>
325 </varlistentry>
326
327 <varlistentry>
328 <term><option>--cat</option></term>
329
330 <listitem><para>When inspecting portable service images, show the (unprocessed) contents of the metadata files
331 pulled from the image, instead of brief summaries. Specifically, this will show the
332 <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> and unit file
333 contents of the image.</para></listitem>
334 </varlistentry>
335
e2c1ddcc
LB
336 <varlistentry>
337 <term><option>--enable</option></term>
338
339 <listitem><para>Immediately enable/disable the portable service after attaching/detaching.</para></listitem>
340 </varlistentry>
341
342 <varlistentry>
343 <term><option>--now</option></term>
344
e26fe5f9
LB
345 <listitem><para>Immediately start/stop/restart the portable service after attaching/before
346 detaching/after upgrading.</para></listitem>
e2c1ddcc
LB
347 </varlistentry>
348
31c33315
LB
349 <varlistentry>
350 <term><option>--no-block</option></term>
351
352 <listitem><para>Don't block waiting for attach --now to complete.</para></listitem>
353 </varlistentry>
354
907952bb
LB
355 <varlistentry>
356 <term><option>--extension=</option><replaceable>PATH</replaceable></term>
357
358 <listitem><para>Add an additional image <replaceable>PATH</replaceable> as an overlay on
359 top of <replaceable>IMAGE</replaceable> when attaching/detaching. This argument can be specified
360 multiple times, in which case the order in which images are laid down follows the rules specified in
361 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
362 for the <varname>ExtensionImages=</varname> directive.</para>
363
364 <para>Note that the same extensions have to be specified, in the same order, when attaching
365 and detaching.</para></listitem>
366 </varlistentry>
367
e1fac8a6
ZJS
368 <xi:include href="user-system-options.xml" xpointer="host" />
369 <xi:include href="user-system-options.xml" xpointer="machine" />
370
371 <xi:include href="standard-options.xml" xpointer="no-pager" />
372 <xi:include href="standard-options.xml" xpointer="no-legend" />
373 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
374 <xi:include href="standard-options.xml" xpointer="help" />
375 <xi:include href="standard-options.xml" xpointer="version" />
376 </variablelist>
377 </refsect1>
378
a8c42bb8
LP
379 <refsect1>
380 <title>Files and Directories</title>
381
382 <para>Portable service images are preferably stored in <filename>/var/lib/portables/</filename>, but are also
383 searched for in <filename>/etc/portables/</filename>, <filename>/run/systemd/portables/</filename>,
384 <filename>/usr/local/lib/portables/</filename> and <filename>/usr/lib/portables/</filename>. It's recommended not
385 to place image files directly in <filename>/etc/portables/</filename> or
386 <filename>/run/systemd/portables/</filename> (as these are generally not suitable for storing large or non-textual
387 data), but use these directories only for linking images located elsewhere into the image search path.</para>
83f72cd6
LP
388
389 <para>When a portable service image is attached, matching unit files are copied onto the host into the
390 <filename>/etc/systemd/system.attached/</filename> and <filename>/run/systemd/system.attached/</filename>
391 directories. When an image is detached, the unit files are removed again from these directories.</para>
a8c42bb8
LP
392 </refsect1>
393
394 <refsect1>
395 <title>Profiles</title>
396
397 <para>When portable service images are attached a "profile" drop-in is linked in, which may be used to enforce
398 additional security (and other) restrictions locally. Four profile drop-ins are defined by default, and shipped in
399 <filename>/usr/lib/systemd/portable/profile/</filename>. Additional, local profiles may be defined by placing them
400 in <filename>/etc/systemd/portable/profile/</filename>. The default profiles are:</para>
401
402 <table>
403 <title>Profiles</title>
404 <tgroup cols='2'>
405 <colspec colname='state'/>
406 <colspec colname='description'/>
407 <thead>
408 <row>
409 <entry>Name</entry>
410 <entry>Description</entry>
411 </row>
412 </thead>
413 <tbody>
414 <row>
415 <entry><filename>default</filename></entry>
416 <entry>This is the default profile if no other profile name is set via the <option>--profile=</option> (see above). It's fairly restrictive, but should be useful for common, unprivileged system workloads. This includes write access to the logging framework, as well as IPC access to the D-Bus system.</entry>
417 </row>
418 <row>
419 <entry><filename>nonetwork</filename></entry>
420 <entry>Very similar to <filename>default</filename>, but networking is turned off for any services of the portable service image.</entry>
421 </row>
422 <row>
423 <entry><filename>strict</filename></entry>
424 <entry>A profile with very strict settings. This profile excludes IPC (D-Bus) and network access.</entry>
425 </row>
426 <row>
427 <entry><filename>trusted</filename></entry>
428 <entry>A profile with very relaxed settings. In this profile the services run with full privileges.</entry>
429 </row>
430 </tbody>
431 </tgroup>
432 </table>
433
e9dd6984 434 <para>For details on these profiles and their effects see their precise definitions,
a8c42bb8
LP
435 e.g. <filename>/usr/lib/systemd/portable/profile/default/service.conf</filename> and similar.</para>
436 </refsect1>
437
438 <refsect1>
439 <title>Exit status</title>
440
441 <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
442 </refsect1>
443
4ef3ca34 444 <xi:include href="common-variables.xml" />
a8c42bb8
LP
445
446 <refsect1>
447 <title>See Also</title>
448 <para>
449 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
23e5c8d2 450 <citerefentry><refentrytitle>org.freedesktop.portable1</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
a8c42bb8
LP
451 <citerefentry><refentrytitle>systemd-portabled.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
452 </para>
453 </refsect1>
454
455</refentry>