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.
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. The image(s) must contain an extension-release file with
297           metadata that matches what is defined in the os-release of IMAGE.
298           See: os-release(5).
299
300           Note that the same extensions have to be specified, in the same
301           order, when attaching and detaching.
302
303       -H, --host=
304           Execute the operation remotely. Specify a hostname, or a username
305           and hostname separated by "@", to connect to. The hostname may
306           optionally be suffixed by a port ssh is listening on, separated by
307           ":", and then a container name, separated by "/", which connects
308           directly to a specific container on the specified host. This will
309           use SSH to talk to the remote machine manager instance. Container
310           names may be enumerated with machinectl -H HOST. Put IPv6 addresses
311           in brackets.
312
313       -M, --machine=
314           Execute operation on a local container. Specify a container name to
315           connect to, optionally prefixed by a user name to connect as and a
316           separating "@" character. If the special string ".host" is used in
317           place of the container name, a connection to the local system is
318           made (which is useful to connect to a specific user's user bus:
319           "--user --machine=lennart@.host"). If the "@" syntax is not used,
320           the connection is made as root user. If the "@" syntax is used
321           either the left hand side or the right hand side may be omitted
322           (but not both) in which case the local user name and ".host" are
323           implied.
324
325       --no-pager
326           Do not pipe output into a pager.
327
328       --no-legend
329           Do not print the legend, i.e. column headers and the footer with
330           hints.
331
332       --no-ask-password
333           Do not query the user for authentication for privileged operations.
334
335       -h, --help
336           Print a short help text and exit.
337
338       --version
339           Print a short version string and exit.
340

FILES AND DIRECTORIES

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

PROFILES

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

EXIT STATUS

403       On success, 0 is returned, a non-zero failure code otherwise.
404

ENVIRONMENT

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

SEE ALSO

530       systemd(1), org.freedesktop.portable1(5), systemd-portabled.service(8)
531
532
533
534systemd 250                                                     PORTABLECTL(1)
Impressum