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 convencience 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       inspect IMAGE [PREFIX...]
134           Extracts various metadata from a portable service image and
135           presents it to the caller. Specifically, the os-release(5) file of
136           the image is retrieved as well as all matching unit files. By
137           default a short summary showing the most relevant metadata in
138           combination with a list of matching unit files is shown (that is
139           the unit files attach would install to the host system). If
140           combined with --cat (see above), the os-release data and the units
141           files' contents is displayed unprocessed. This command is useful to
142           determine whether an image qualifies as portable service image, and
143           which unit files are included. This command expects the path to the
144           image as parameter, optionally followed by a list of unit file
145           prefixes to consider, similar to the attach command described
146           above.
147
148       is-attached IMAGE
149           Determines whether the specified image is currently attached or
150           not. Unless combined with the --quiet switch this will show a short
151           state identifier for the image. Specifically:
152
153           Table 1. Image attachment states
154           ┌─────────────────┬────────────────────────────┐
155State            Description                
156           ├─────────────────┼────────────────────────────┤
157detached         │ The image is currently not │
158           │                 │ attached.                  │
159           ├─────────────────┼────────────────────────────┤
160attached         │ The image is currently     │
161           │                 │ attached, i.e. its unit    │
162           │                 │ files have been made       │
163           │                 │ available to the host      │
164           │                 │ system.                    │
165           ├─────────────────┼────────────────────────────┤
166attached-runtime │ Like attached, but the     │
167           │                 │ unit files have been made  │
168           │                 │ available transiently      │
169           │                 │ only, i.e. the attach      
170           │                 │ command has been invoked   │
171           │                 │ with the --runtime option. │
172           ├─────────────────┼────────────────────────────┤
173enabled          │ The image is currently     │
174           │                 │ attached, and at least one │
175           │                 │ unit file associated with  │
176           │                 │ it has been enabled.       │
177           ├─────────────────┼────────────────────────────┤
178enabled-runtime  │ Like enabled, but the unit │
179           │                 │ files have been made       │
180           │                 │ available transiently      │
181           │                 │ only, i.e. the attach      
182           │                 │ command has been invoked   │
183           │                 │ with the --runtime option. │
184           ├─────────────────┼────────────────────────────┤
185running          │ The image is currently     │
186           │                 │ attached, and at least one │
187           │                 │ unit file associated with  │
188           │                 │ it is running.             │
189           ├─────────────────┼────────────────────────────┤
190running-runtime  │ The image is currently     │
191           │                 │ attached transiently, and  │
192           │                 │ at least one unit file     │
193           │                 │ associated with it is      │
194           │                 │ running.                   │
195           └─────────────────┴────────────────────────────┘
196
197       read-only IMAGE [BOOL]
198           Marks or (unmarks) a portable service image read-only. Takes an
199           image name, followed by a boolean as arguments. If the boolean is
200           omitted, positive is implied, i.e. the image is marked read-only.
201
202       remove IMAGE...
203           Removes one or more portable service images. Note that this command
204           will only remove the specified image path itself — it refers to a
205           symbolic link then the symbolic link is removed and not the image
206           it points to.
207
208       set-limit [IMAGE] BYTES
209           Sets the maximum size in bytes that a specific portable service
210           image, or all images, may grow up to on disk (disk quota). Takes
211           either one or two parameters. The first, optional parameter refers
212           to a portable service image name. If specified, the size limit of
213           the specified image is changed. If omitted, the overall size limit
214           of the sum of all images stored locally is changed. The final
215           argument specifies the size limit in bytes, possibly suffixed by
216           the usual K, M, G, T units. If the size limit shall be disabled,
217           specify "-" as size.
218
219           Note that per-image size limits are only supported on btrfs file
220           systems. Also, depending on BindPaths= settings in the portable
221           service's unit files directories from the host might be visible in
222           the image environment during runtime which are not affected by this
223           setting, as only the image itself is counted against this limit.
224

OPTIONS

226       The following options are understood:
227
228       -q, --quiet
229           Suppresses additional informational output while running.
230
231       -p PROFILE, --profile=PROFILE
232           When attaching an image, select the profile to use. By default the
233           "default" profile is used. For details about profiles, see below.
234
235       --copy=
236           When attaching an image, select whether to prefer copying or
237           symlinking of files installed into the host system. Takes one of
238           "copy" (to prefer copying of files), "symlink" (to prefer creation
239           of symbolic links) or "auto" for an intermediary mode where
240           security profile drop-ins are symlinked while unit files are
241           copied. Note that this option expresses a preference only, in cases
242           where symbolic links cannot be created — for example when the image
243           operated on is a raw disk image, and hence not directly
244           referentiable from the host file system — copying of files is used
245           unconditionally.
246
247       --runtime
248           When specified the unit and drop-in files are placed in
249           /run/systemd/system.attached/ instead of
250           /etc/systemd/system.attached/. Images attached with this option set
251           hence remain attached only until the next reboot, while they are
252           normally attached persistently.
253
254       --no-reload
255           Don't reload the service manager after attaching or detaching a
256           portable service image. Normally the service manager is reloaded to
257           ensure it is aware of added or removed unit files.
258
259       --cat
260           When inspecting portable service images, show the (unprocessed)
261           contents of the metadata files pulled from the image, instead of
262           brief summaries. Specifically, this will show the os-release(5) and
263           unit file contents of the image.
264
265       --enable
266           Immediately enable/disable the portable service after
267           attaching/detaching.
268
269       --now
270           Immediately start/stop the portable service after attaching/before
271           detaching.
272
273       --no-block
274           Don't block waiting for attach --now to complete.
275
276       -H, --host=
277           Execute the operation remotely. Specify a hostname, or a username
278           and hostname separated by "@", to connect to. The hostname may
279           optionally be suffixed by a port ssh is listening on, separated by
280           ":", and then a container name, separated by "/", which connects
281           directly to a specific container on the specified host. This will
282           use SSH to talk to the remote machine manager instance. Container
283           names may be enumerated with machinectl -H HOST. Put IPv6 addresses
284           in brackets.
285
286       -M, --machine=
287           Execute operation on a local container. Specify a container name to
288           connect to.
289
290       --no-pager
291           Do not pipe output into a pager.
292
293       --no-legend
294           Do not print the legend, i.e. column headers and the footer with
295           hints.
296
297       --no-ask-password
298           Do not query the user for authentication for privileged operations.
299
300       -h, --help
301           Print a short help text and exit.
302
303       --version
304           Print a short version string and exit.
305

FILES AND DIRECTORIES

307       Portable service images are preferably stored in /var/lib/portables/,
308       but are also searched for in /etc/portables/, /run/systemd/portables/,
309       /usr/local/lib/portables/ and /usr/lib/portables/. It's recommended not
310       to place image files directly in /etc/portables/ or
311       /run/systemd/portables/ (as these are generally not suitable for
312       storing large or non-textual data), but use these directories only for
313       linking images located elsewhere into the image search path.
314
315       When a portable service image is attached, matching unit files are
316       copied onto the host into the /etc/systemd/system.attached/ and
317       /run/systemd/system.attached/ directories. When an image is detached,
318       the unit files are removed again from these directories.
319

PROFILES

321       When portable service images are attached a "profile" drop-in is linked
322       in, which may be used to enforce additional security (and other)
323       restrictions locally. Four profile drop-ins are defined by default, and
324       shipped in /usr/lib/systemd/portable/profile/. Additional, local
325       profiles may be defined by placing them in
326       /etc/systemd/portable/profile/. The default profiles are:
327
328       Table 2. Profiles
329       ┌──────────┬────────────────────────────┐
330Name      Description                
331       ├──────────┼────────────────────────────┤
332       │default   │ This is the default        │
333       │          │ profile if no other        │
334       │          │ profile name is set via    │
335       │          │ the --profile= (see        │
336       │          │ above). It's fairly        │
337       │          │ restrictive, but should be │
338       │          │ useful for common,         │
339       │          │ unprivileged system        │
340       │          │ workloads. This includes   │
341       │          │ write access to the        │
342       │          │ logging framework, as well │
343       │          │ as IPC access to the D-Bus │
344       │          │ system.                    │
345       ├──────────┼────────────────────────────┤
346       │nonetwork │ Very similar to default,   │
347       │          │ but networking is turned   │
348       │          │ off for any services of    │
349       │          │ the portable service       │
350       │          │ image.                     │
351       ├──────────┼────────────────────────────┤
352       │strict    │ A profile with very strict │
353       │          │ settings. This profile     │
354       │          │ excludes IPC (D-Bus) and   │
355       │          │ network access.            │
356       ├──────────┼────────────────────────────┤
357       │trusted   │ A profile with very        │
358       │          │ relaxed settings. In this  │
359       │          │ profile the services run   │
360       │          │ with full privileges.      │
361       └──────────┴────────────────────────────┘
362
363       For details on these profiles and their effects see their precise
364       definitions, e.g.
365       /usr/lib/systemd/portable/profile/default/service.conf and similar.
366

EXIT STATUS

368       On success, 0 is returned, a non-zero failure code otherwise.
369

ENVIRONMENT

371       $SYSTEMD_PAGER
372           Pager to use when --no-pager is not given; overrides $PAGER. If
373           neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known
374           pager implementations are tried in turn, including less(1) and
375           more(1), until one is found. If no pager implementation is
376           discovered no pager is invoked. Setting this environment variable
377           to an empty string or the value "cat" is equivalent to passing
378           --no-pager.
379
380       $SYSTEMD_LESS
381           Override the options passed to less (by default "FRSXMK").
382
383           Users might want to change two options in particular:
384
385           K
386               This option instructs the pager to exit immediately when Ctrl+C
387               is pressed. To allow less to handle Ctrl+C itself to switch
388               back to the pager command prompt, unset this option.
389
390               If the value of $SYSTEMD_LESS does not include "K", and the
391               pager that is invoked is less, Ctrl+C will be ignored by the
392               executable, and needs to be handled by the pager.
393
394           X
395               This option instructs the pager to not send termcap
396               initialization and deinitialization strings to the terminal. It
397               is set by default to allow command output to remain visible in
398               the terminal even after the pager exits. Nevertheless, this
399               prevents some pager functionality from working, in particular
400               paged output cannot be scrolled with the mouse.
401
402           See less(1) for more discussion.
403
404       $SYSTEMD_LESSCHARSET
405           Override the charset passed to less (by default "utf-8", if the
406           invoking terminal is determined to be UTF-8 compatible).
407
408       $SYSTEMD_PAGERSECURE
409           Takes a boolean argument. When true, the "secure" mode of the pager
410           is enabled; if false, disabled. If $SYSTEMD_PAGERSECURE is not set
411           at all, secure mode is enabled if the effective UID is not the same
412           as the owner of the login session, see geteuid(2) and
413           sd_pid_get_owner_uid(3). In secure mode, LESSSECURE=1 will be set
414           when invoking the pager, and the pager shall disable commands that
415           open or create new files or start new subprocesses. When
416           $SYSTEMD_PAGERSECURE is not set at all, pagers which are not known
417           to implement secure mode will not be used. (Currently only less(1)
418           implements secure mode.)
419
420           Note: when commands are invoked with elevated privileges, for
421           example under sudo(8) or pkexec(1), care must be taken to ensure
422           that unintended interactive features are not enabled. "Secure" mode
423           for the pager may be enabled automatically as describe above.
424           Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited
425           environment allows the user to invoke arbitrary commands. Note that
426           if the $SYSTEMD_PAGER or $PAGER variables are to be honoured,
427           $SYSTEMD_PAGERSECURE must be set too. It might be reasonable to
428           completly disable the pager using --no-pager instead.
429
430       $SYSTEMD_COLORS
431           The value must be a boolean. Controls whether colorized output
432           should be generated. This can be specified to override the decision
433           that systemd makes based on $TERM and what the console is connected
434           to.
435
436       $SYSTEMD_URLIFY
437           The value must be a boolean. Controls whether clickable links
438           should be generated in the output for terminal emulators supporting
439           this. This can be specified to override the decision that systemd
440           makes based on $TERM and other conditions.
441

SEE ALSO

443       systemd(1), systemd-portabled.service(8)
444
445
446
447systemd 246                                                     PORTABLECTL(1)
Impressum