1PORTABLECTL(1)                    portablectl                   PORTABLECTL(1)
2
3
4

NAME

6       portablectl - Attach, detach or inspect portable service images
7

SYNOPSIS

9       portablectl [OPTIONS...] {COMMAND} [NAME...]
10

DESCRIPTION

12       portablectl may be used to attach, detach or inspect portable service
13       images. It's primarily a command interfacing with systemd-
14       portabled.service(8).
15
16       Portable service images contain an OS file system tree along with
17       systemd(1) unit file information. A service image may be "attached" to
18       the local system. If attached, a set of unit files are copied from the
19       image to the host, and extended with RootDirectory= or RootImage=
20       assignments (in case of service units) pointing to the image file or
21       directory, ensuring the services will run within the file system
22       context of the image.
23
24       Portable service images are an efficient way to bundle multiple related
25       services and other units together, and transfer them as a whole between
26       systems. When these images are attached the local system the contained
27       units may run in most ways like regular system-provided units, either
28       with full privileges or inside strict sandboxing, depending on the
29       selected configuration. For more details, see Portable Services[1].
30
31       Specifically portable service images may be of the following kind:
32
33       •   Directory trees containing an OS, including the top-level
34           directories /usr/, /etc/, and so on.
35
36       •   btrfs subvolumes containing OS trees, similar to normal directory
37           trees.
38
39       •   Binary "raw" disk images containing MBR or GPT partition tables and
40           Linux file system partitions. (These must be regular files, with
41           the .raw suffix.)
42

COMMANDS

44       The following commands are understood:
45
46       list
47           List available portable service images. This will list all portable
48           service images discovered in the portable image search paths (see
49           below), along with brief metadata and state information. Note that
50           many of the commands below may both operate on images inside and
51           outside of the search paths. This command is hence mostly a
52           convenience option, the commands are generally not restricted to
53           what this list shows.
54
55       attach IMAGE [PREFIX...]
56           Attach a portable service image to the host system. Expects a file
57           system path to a portable service image file or directory as first
58           argument. If the specified path contains no slash character ("/")
59           it is understood as image filename that is searched for in the
60           portable service image search paths (see below). To reference a
61           file in the current working directory prefix the filename with "./"
62           to avoid this search path logic.
63
64           When a portable service is attached four operations are executed:
65
66            1. All unit files of types .service, .socket, .target, .timer and
67               .path which match the indicated unit file name prefix are
68               copied from the image to the host's
69               /etc/systemd/system.attached/ directory (or
70               /run/systemd/system.attached/ — depending whether --runtime is
71               specified, see above), which is included in the built-in unit
72               search path of the system service manager.
73
74            2. For unit files of type .service a drop-in is added to these
75               copies that adds RootDirectory= or RootImage= settings (see
76               systemd.unit(5) for details), that ensures these services are
77               run within the file system of the originating portable service
78               image.
79
80            3. A second drop-in is created: the "profile" drop-in, that may
81               contain additional security settings (and other settings). A
82               number of profiles are available by default but administrators
83               may define their own ones. See below.
84
85            4. If the portable service image file is not already in the search
86               path (see below), a symbolic link to it is created in
87               /etc/portables/ or /run/portables/, to make sure it is included
88               in it.
89
90           By default all unit files whose names start with a prefix generated
91           from the image's file name are copied out. Specifically, the prefix
92           is determined from the image file name with any suffix such as .raw
93           removed, truncated at the first occurrence of an underscore
94           character ("_"), if there is one. The underscore logic is supposed
95           to be used to versioning so that the an image file foobar_47.11.raw
96           will result in a unit file matching prefix of foobar. This prefix
97           is then compared with all unit files names contained in the image
98           in the usual directories, but only unit file names where the prefix
99           is followed by "-", "."  or "@" are considered. Example: if a
100           portable service image file is named foobar_47.11.raw then by
101           default all its unit files with names such as
102           foobar-quux-waldi.service, foobar.service or foobar@.service will
103           be considered. It's possible to override the matching prefix: all
104           strings listed on the command line after the image file name are
105           considered prefixes, overriding the implicit logic where the prefix
106           is derived from the image file name.
107
108           By default, after the unit files are attached the service manager's
109           configuration is reloaded, except when --no-reload is specified
110           (see above). This ensures that the new units made available to the
111           service manager are seen by it.
112
113           If --now and/or --enable are passed, the portable service(s) are
114           immediately started (blocking operation unless --no-block is
115           passed) and/or enabled after attaching the image.
116
117       detach IMAGE [PREFIX...]
118           Detaches a portable service image from the host. This undoes the
119           operations executed by the attach command above, and removes the
120           unit file copies, drop-ins and image symlink again. This command
121           expects an image name or path as parameter. Note that if a path is
122           specified only the last component of it (i.e. the file or directory
123           name itself, not the path to it) is used for finding matching unit
124           files. This is a convenience feature to allow all arguments passed
125           as attach also to detach.
126
127           If --now and/or --enable are passed, the portable service(s) are
128           immediately stopped (blocking operation) and/or disabled before
129           detaching the image. Prefix(es) are also accepted, to be used in
130           case the unit names do not match the image name as described in the
131           attach.
132
133       reattach IMAGE [PREFIX...]
134           Detaches an existing portable service image from the host, and
135           immediately attaches it again. This is useful in case the image was
136           replaced. Running units are not stopped during the process. Partial
137           matching, to allow for different versions in the image name, is
138           allowed: only the part before the first "_" character has to match.
139           If the new image doesn't exist, the existing one will not be
140           detached. The parameters follow the same syntax as the attach
141           command.
142
143           If --now and/or --enable are passed, the portable service(s) are
144           immediately stopped if removed, started and/or enabled if added, or
145           restarted if updated. Prefixes are also accepted, in the same way
146           as described in the attach case.
147
148       inspect IMAGE [PREFIX...]
149           Extracts various metadata from a portable service image and
150           presents it to the caller. Specifically, the os-release(5) file of
151           the image is retrieved as well as all matching unit files. By
152           default a short summary showing the most relevant metadata in
153           combination with a list of matching unit files is shown (that is
154           the unit files attach would install to the host system). If
155           combined with --cat (see above), the os-release data and the units
156           files' contents is displayed unprocessed. This command is useful to
157           determine whether an image qualifies as portable service image, and
158           which unit files are included. This command expects the path to the
159           image as parameter, optionally followed by a list of unit file
160           prefixes to consider, similar to the attach command described
161           above.
162
163       is-attached IMAGE
164           Determines whether the specified image is currently attached or
165           not. Unless combined with the --quiet switch this will show a short
166           state identifier for the image. Specifically:
167
168           Table 1. Image attachment states
169           ┌─────────────────┬────────────────────────────┐
170State            Description                
171           ├─────────────────┼────────────────────────────┤
172detached         │ The image is currently not │
173           │                 │ attached.                  │
174           ├─────────────────┼────────────────────────────┤
175attached         │ The image is currently     │
176           │                 │ attached, i.e. its unit    │
177           │                 │ files have been made       │
178           │                 │ available to the host      │
179           │                 │ system.                    │
180           ├─────────────────┼────────────────────────────┤
181attached-runtime │ Like attached, but the     │
182           │                 │ unit files have been made  │
183           │                 │ available transiently      │
184           │                 │ only, i.e. the attach      
185           │                 │ command has been invoked   │
186           │                 │ with the --runtime option. │
187           ├─────────────────┼────────────────────────────┤
188enabled          │ The image is currently     │
189           │                 │ attached, and at least one │
190           │                 │ unit file associated with  │
191           │                 │ it has been enabled.       │
192           ├─────────────────┼────────────────────────────┤
193enabled-runtime  │ Like enabled, but the unit │
194           │                 │ files have been made       │
195           │                 │ available transiently      │
196           │                 │ only, i.e. the attach      
197           │                 │ command has been invoked   │
198           │                 │ with the --runtime option. │
199           ├─────────────────┼────────────────────────────┤
200running          │ The image is currently     │
201           │                 │ attached, and at least one │
202           │                 │ unit file associated with  │
203           │                 │ it is running.             │
204           ├─────────────────┼────────────────────────────┤
205running-runtime  │ The image is currently     │
206           │                 │ attached transiently, and  │
207           │                 │ at least one unit file     │
208           │                 │ associated with it is      │
209           │                 │ running.                   │
210           └─────────────────┴────────────────────────────┘
211
212       read-only IMAGE [BOOL]
213           Marks or (unmarks) a portable service image read-only. Takes an
214           image name, followed by a boolean as arguments. If the boolean is
215           omitted, positive is implied, i.e. the image is marked read-only.
216
217       remove IMAGE...
218           Removes one or more portable service images. Note that this command
219           will only remove the specified image path itself — it refers to a
220           symbolic link then the symbolic link is removed and not the image
221           it points to.
222
223       set-limit [IMAGE] BYTES
224           Sets the maximum size in bytes that a specific portable service
225           image, or all images, may grow up to on disk (disk quota). Takes
226           either one or two parameters. The first, optional parameter refers
227           to a portable service image name. If specified, the size limit of
228           the specified image is changed. If omitted, the overall size limit
229           of the sum of all images stored locally is changed. The final
230           argument specifies the size limit in bytes, possibly suffixed by
231           the usual K, M, G, T units. If the size limit shall be disabled,
232           specify "-" as size.
233
234           Note that per-image size limits are only supported on btrfs file
235           systems. Also, depending on BindPaths= settings in the portable
236           service's unit files directories from the host might be visible in
237           the image environment during runtime which are not affected by this
238           setting, as only the image itself is counted against this limit.
239

OPTIONS

241       The following options are understood:
242
243       -q, --quiet
244           Suppresses additional informational output while running.
245
246       -p PROFILE, --profile=PROFILE
247           When attaching an image, select the profile to use. By default the
248           "default" profile is used. For details about profiles, see below.
249
250       --copy=
251           When attaching an image, select whether to prefer copying or
252           symlinking of files installed into the host system. Takes one of
253           "copy" (to prefer copying of files), "symlink" (to prefer creation
254           of symbolic links) or "auto" for an intermediary mode where
255           security profile drop-ins are symlinked while unit files are
256           copied. Note that this option expresses a preference only, in cases
257           where symbolic links cannot be created — for example when the image
258           operated on is a raw disk image, and hence not directly
259           referentiable from the host file system — copying of files is used
260           unconditionally.
261
262       --runtime
263           When specified the unit and drop-in files are placed in
264           /run/systemd/system.attached/ instead of
265           /etc/systemd/system.attached/. Images attached with this option set
266           hence remain attached only until the next reboot, while they are
267           normally attached persistently.
268
269       --no-reload
270           Don't reload the service manager after attaching or detaching a
271           portable service image. Normally the service manager is reloaded to
272           ensure it is aware of added or removed unit files.
273
274       --cat
275           When inspecting portable service images, show the (unprocessed)
276           contents of the metadata files pulled from the image, instead of
277           brief summaries. Specifically, this will show the os-release(5) and
278           unit file contents of the image.
279
280       --enable
281           Immediately enable/disable the portable service after
282           attaching/detaching.
283
284       --now
285           Immediately start/stop/restart the portable service after
286           attaching/before detaching/after upgrading.
287
288       --no-block
289           Don't block waiting for attach --now to complete.
290
291       --extension=PATH
292           Add an additional image PATH as an overlay on top of IMAGE when
293           attaching/detaching. This argument can be specified multiple times,
294           in which case the order in which images are laid down follows the
295           rules specified in systemd.exec(5) for the ExtensionImages=
296           directive and for the systemd-sysext(8) tool. The image(s) must
297           contain an extension-release file with metadata that matches what
298           is defined in the os-release of IMAGE. See: os-release(5). Images
299           can be block images, btrfs subvolumes or directories. For more
300           information on portable services with extensions, see the
301           "Extension Images" paragraph on Portable Services[1].
302
303           Note that the same extensions have to be specified, in the same
304           order, when attaching and detaching.
305
306       -H, --host=
307           Execute the operation remotely. Specify a hostname, or a username
308           and hostname separated by "@", to connect to. The hostname may
309           optionally be suffixed by a port ssh is listening on, separated by
310           ":", and then a container name, separated by "/", which connects
311           directly to a specific container on the specified host. This will
312           use SSH to talk to the remote machine manager instance. Container
313           names may be enumerated with machinectl -H HOST. Put IPv6 addresses
314           in brackets.
315
316       -M, --machine=
317           Execute operation on a local container. Specify a container name to
318           connect to, optionally prefixed by a user name to connect as and a
319           separating "@" character. If the special string ".host" is used in
320           place of the container name, a connection to the local system is
321           made (which is useful to connect to a specific user's user bus:
322           "--user --machine=lennart@.host"). If the "@" syntax is not used,
323           the connection is made as root user. If the "@" syntax is used
324           either the left hand side or the right hand side may be omitted
325           (but not both) in which case the local user name and ".host" are
326           implied.
327
328       --no-pager
329           Do not pipe output into a pager.
330
331       --no-legend
332           Do not print the legend, i.e. column headers and the footer with
333           hints.
334
335       --no-ask-password
336           Do not query the user for authentication for privileged operations.
337
338       -h, --help
339           Print a short help text and exit.
340
341       --version
342           Print a short version string and exit.
343

FILES AND DIRECTORIES

345       Portable service images are preferably stored in /var/lib/portables/,
346       but are also searched for in /etc/portables/, /run/systemd/portables/,
347       /usr/local/lib/portables/ and /usr/lib/portables/. It's recommended not
348       to place image files directly in /etc/portables/ or
349       /run/systemd/portables/ (as these are generally not suitable for
350       storing large or non-textual data), but use these directories only for
351       linking images located elsewhere into the image search path.
352
353       When a portable service image is attached, matching unit files are
354       copied onto the host into the /etc/systemd/system.attached/ and
355       /run/systemd/system.attached/ directories. When an image is detached,
356       the unit files are removed again from these directories.
357

PROFILES

359       When portable service images are attached a "profile" drop-in is linked
360       in, which may be used to enforce additional security (and other)
361       restrictions locally. Four profile drop-ins are defined by default, and
362       shipped in /usr/lib/systemd/portable/profile/. Additional, local
363       profiles may be defined by placing them in
364       /etc/systemd/portable/profile/. The default profiles are:
365
366       Table 2. Profiles
367       ┌──────────┬────────────────────────────┐
368Name      Description                
369       ├──────────┼────────────────────────────┤
370       │default   │ This is the default        │
371       │          │ profile if no other        │
372       │          │ profile name is set via    │
373       │          │ the --profile= (see        │
374       │          │ above). It's fairly        │
375       │          │ restrictive, but should be │
376       │          │ useful for common,         │
377       │          │ unprivileged system        │
378       │          │ workloads. This includes   │
379       │          │ write access to the        │
380       │          │ logging framework, as well │
381       │          │ as IPC access to the D-Bus │
382       │          │ system.                    │
383       ├──────────┼────────────────────────────┤
384       │nonetwork │ Very similar to default,   │
385       │          │ but networking is turned   │
386       │          │ off for any services of    │
387       │          │ the portable service       │
388       │          │ image.                     │
389       ├──────────┼────────────────────────────┤
390       │strict    │ A profile with very strict │
391       │          │ settings. This profile     │
392       │          │ excludes IPC (D-Bus) and   │
393       │          │ network access.            │
394       ├──────────┼────────────────────────────┤
395       │trusted   │ A profile with very        │
396       │          │ relaxed settings. In this  │
397       │          │ profile the services run   │
398       │          │ with full privileges.      │
399       └──────────┴────────────────────────────┘
400
401       For details on these profiles and their effects see their precise
402       definitions, e.g.
403       /usr/lib/systemd/portable/profile/default/service.conf and similar.
404

EXIT STATUS

406       On success, 0 is returned, a non-zero failure code otherwise.
407

ENVIRONMENT

409       $SYSTEMD_LOG_LEVEL
410           The maximum log level of emitted messages (messages with a higher
411           log level, i.e. less important ones, will be suppressed). Either
412           one of (in order of decreasing importance) emerg, alert, crit, err,
413           warning, notice, info, debug, or an integer in the range 0...7. See
414           syslog(3) for more information.
415
416       $SYSTEMD_LOG_COLOR
417           A boolean. If true, messages written to the tty will be colored
418           according to priority.
419
420           This setting is only useful when messages are written directly to
421           the terminal, because journalctl(1) and other tools that display
422           logs will color messages based on the log level on their own.
423
424       $SYSTEMD_LOG_TIME
425           A boolean. If true, console log messages will be prefixed with a
426           timestamp.
427
428           This setting is only useful when messages are written directly to
429           the terminal or a file, because journalctl(1) and other tools that
430           display logs will attach timestamps based on the entry metadata on
431           their own.
432
433       $SYSTEMD_LOG_LOCATION
434           A boolean. If true, messages will be prefixed with a filename and
435           line number in the source code where the message originates.
436
437           Note that the log location is often attached as metadata to journal
438           entries anyway. Including it directly in the message text can
439           nevertheless be convenient when debugging programs.
440
441       $SYSTEMD_LOG_TID
442           A boolean. If true, messages will be prefixed with the current
443           numerical thread ID (TID).
444
445           Note that the this information is attached as metadata to journal
446           entries anyway. Including it directly in the message text can
447           nevertheless be convenient when debugging programs.
448
449       $SYSTEMD_LOG_TARGET
450           The destination for log messages. One of console (log to the
451           attached tty), console-prefixed (log to the attached tty but with
452           prefixes encoding the log level and "facility", see syslog(3), kmsg
453           (log to the kernel circular log buffer), journal (log to the
454           journal), journal-or-kmsg (log to the journal if available, and to
455           kmsg otherwise), auto (determine the appropriate log target
456           automatically, the default), null (disable log output).
457
458       $SYSTEMD_PAGER
459           Pager to use when --no-pager is not given; overrides $PAGER. If
460           neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known
461           pager implementations are tried in turn, including less(1) and
462           more(1), until one is found. If no pager implementation is
463           discovered no pager is invoked. Setting this environment variable
464           to an empty string or the value "cat" is equivalent to passing
465           --no-pager.
466
467           Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER (as well
468           as $PAGER) will be silently ignored.
469
470       $SYSTEMD_LESS
471           Override the options passed to less (by default "FRSXMK").
472
473           Users might want to change two options in particular:
474
475           K
476               This option instructs the pager to exit immediately when Ctrl+C
477               is pressed. To allow less to handle Ctrl+C itself to switch
478               back to the pager command prompt, unset this option.
479
480               If the value of $SYSTEMD_LESS does not include "K", and the
481               pager that is invoked is less, Ctrl+C will be ignored by the
482               executable, and needs to be handled by the pager.
483
484           X
485               This option instructs the pager to not send termcap
486               initialization and deinitialization strings to the terminal. It
487               is set by default to allow command output to remain visible in
488               the terminal even after the pager exits. Nevertheless, this
489               prevents some pager functionality from working, in particular
490               paged output cannot be scrolled with the mouse.
491
492           See less(1) for more discussion.
493
494       $SYSTEMD_LESSCHARSET
495           Override the charset passed to less (by default "utf-8", if the
496           invoking terminal is determined to be UTF-8 compatible).
497
498       $SYSTEMD_PAGERSECURE
499           Takes a boolean argument. When true, the "secure" mode of the pager
500           is enabled; if false, disabled. If $SYSTEMD_PAGERSECURE is not set
501           at all, secure mode is enabled if the effective UID is not the same
502           as the owner of the login session, see geteuid(2) and
503           sd_pid_get_owner_uid(3). In secure mode, LESSSECURE=1 will be set
504           when invoking the pager, and the pager shall disable commands that
505           open or create new files or start new subprocesses. When
506           $SYSTEMD_PAGERSECURE is not set at all, pagers which are not known
507           to implement secure mode will not be used. (Currently only less(1)
508           implements secure mode.)
509
510           Note: when commands are invoked with elevated privileges, for
511           example under sudo(8) or pkexec(1), care must be taken to ensure
512           that unintended interactive features are not enabled. "Secure" mode
513           for the pager may be enabled automatically as describe above.
514           Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited
515           environment allows the user to invoke arbitrary commands. Note that
516           if the $SYSTEMD_PAGER or $PAGER variables are to be honoured,
517           $SYSTEMD_PAGERSECURE must be set too. It might be reasonable to
518           completely disable the pager using --no-pager instead.
519
520       $SYSTEMD_COLORS
521           Takes a boolean argument. When true, systemd and related utilities
522           will use colors in their output, otherwise the output will be
523           monochrome. Additionally, the variable can take one of the
524           following special values: "16", "256" to restrict the use of colors
525           to the base 16 or 256 ANSI colors, respectively. This can be
526           specified to override the automatic decision based on $TERM and
527           what the console is connected to.
528
529       $SYSTEMD_URLIFY
530           The value must be a boolean. Controls whether clickable links
531           should be generated in the output for terminal emulators supporting
532           this. This can be specified to override the decision that systemd
533           makes based on $TERM and other conditions.
534

SEE ALSO

536       systemd(1), systemd-sysext(8), org.freedesktop.portable1(5), systemd-
537       portabled.service(8)
538

NOTES

540        1. Portable Services
541           https://systemd.io/PORTABLE_SERVICES
542
543
544
545systemd 251                                                     PORTABLECTL(1)
Impressum