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
30       Documentation[1].
31
32       Specifically portable service images may be of the following kind:
33
34       •   Directory trees containing an OS, including the top-level
35           directories /usr/, /etc/, and so on.
36
37       •   btrfs subvolumes containing OS trees, similar to normal directory
38           trees.
39
40       •   Binary "raw" disk images containing MBR or GPT partition tables and
41           Linux file system partitions. (These must be regular files, with
42           the .raw suffix.)
43

COMMANDS

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

OPTIONS

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

FILES AND DIRECTORIES

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

PROFILES

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

EXIT STATUS

413       On success, 0 is returned, a non-zero failure code otherwise.
414

ENVIRONMENT

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

SEE ALSO

548       systemd(1), systemd-sysext(8), org.freedesktop.portable1(5), systemd-
549       portabled.service(8)
550

NOTES

552        1. Portable Services Documentation
553           https://systemd.io/PORTABLE_SERVICES
554
555
556
557systemd 254                                                     PORTABLECTL(1)
Impressum