]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/machinectl.xml
man: more hyperlinks and other fixes
[thirdparty/systemd.git] / man / machinectl.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
5fadff33
ZJS
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % entities SYSTEM "custom-entities.ent" >
5%entities;
6]>
db9ecf05 7<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
19887cd0 8
21ac6ff1 9<refentry id="machinectl" conditional='ENABLE_MACHINED'
798d3a52
ZJS
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>machinectl</title>
14 <productname>systemd</productname>
798d3a52
ZJS
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>machinectl</refentrytitle>
19 <manvolnum>1</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>machinectl</refname>
24 <refpurpose>Control the systemd machine manager</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <cmdsynopsis>
29 <command>machinectl</command>
30 <arg choice="opt" rep="repeat">OPTIONS</arg>
31 <arg choice="req">COMMAND</arg>
32 <arg choice="opt" rep="repeat">NAME</arg>
33 </cmdsynopsis>
34 </refsynopsisdiv>
35
36 <refsect1>
37 <title>Description</title>
38
39 <para><command>machinectl</command> may be used to introspect and
40 control the state of the
41 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
42 virtual machine and container registration manager
43 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
91913f58
LP
44
45 <para><command>machinectl</command> may be used to execute
46 operations on machines and images. Machines in this sense are
47 considered running instances of:</para>
48
49 <itemizedlist>
50 <listitem><para>Virtual Machines (VMs) that virtualize hardware
51 to run full operating system (OS) instances (including their kernels)
52 in a virtualized environment on top of the host OS.</para></listitem>
53
54 <listitem><para>Containers that share the hardware and
55 OS kernel with the host OS, in order to run
56 OS userspace instances on top the host OS.</para></listitem>
57
fa69a4c7 58 <listitem><para>The host system itself.</para></listitem>
91913f58
LP
59 </itemizedlist>
60
61 <para>Machines are identified by names that follow the same rules
38b38500 62 as UNIX and DNS hostnames. For details, see below.</para>
fa69a4c7
ZJS
63
64 <para>Machines are instantiated from disk or file system images that
65 frequently — but not necessarily — carry the same name as machines running
66 from them. Images in this sense may be:</para>
91913f58
LP
67
68 <itemizedlist>
fa69a4c7 69 <listitem><para>Directory trees containing an OS, including the
3b121157
ZJS
70 top-level directories <filename>/usr/</filename>,
71 <filename>/etc/</filename>, and so on.</para></listitem>
91913f58 72
576cf244 73 <listitem><para>btrfs subvolumes containing OS trees, similar to regular directory trees.</para></listitem>
91913f58 74
576cf244
LP
75 <listitem><para>Binary "raw" disk image files containing MBR or GPT partition tables and Linux file
76 systems.</para></listitem>
77
78 <listitem><para>Similarly, block devices containing MBR or GPT partition tables and file systems.</para></listitem>
91913f58
LP
79
80 <listitem><para>The file system tree of the host OS itself.</para></listitem>
81 </itemizedlist>
82
798d3a52
ZJS
83 </refsect1>
84
798d3a52
ZJS
85 <refsect1>
86 <title>Commands</title>
87
88 <para>The following commands are understood:</para>
89
90 <refsect2><title>Machine Commands</title><variablelist>
91
92 <varlistentry>
93 <term><command>list</command></term>
94
95 <listitem><para>List currently running (online) virtual
91913f58
LP
96 machines and containers. To enumerate machine images that can
97 be started, use <command>list-images</command> (see
98 below). Note that this command hides the special
99 <literal>.host</literal> machine by default. Use the
aefdc112
AK
100 <option>--all</option> switch to show it.</para>
101
102 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
798d3a52
ZJS
103 </varlistentry>
104
105 <varlistentry>
1eecafb8 106 <term><command>status</command> <replaceable>NAME</replaceable>…</term>
798d3a52 107
28f90ea2 108 <listitem><para>Show runtime status information about
798d3a52
ZJS
109 one or more virtual machines and containers, followed by the
110 most recent log data from the journal. This function is
111 intended to generate human-readable output. If you are looking
112 for computer-parsable output, use <command>show</command>
113 instead. Note that the log data shown is reported by the
114 virtual machine or container manager, and frequently contains
115 console output of the machine, but not necessarily journal
ec07c3c8
AK
116 contents of the machine itself.</para>
117
aefdc112 118 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
798d3a52
ZJS
119 </varlistentry>
120
121 <varlistentry>
1eecafb8 122 <term><command>show</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52 123
e9c880dd
LP
124 <listitem><para>Show properties of one or more registered virtual machines or containers or the manager
125 itself. If no argument is specified, properties of the manager will be shown. If a NAME is specified,
126 properties of this virtual machine or container are shown. By default, empty properties are suppressed. Use
127 <option>--all</option> to show those too. To select specific properties to show, use
128 <option>--property=</option>. This command is intended to be used whenever computer-parsable output is
129 required, and does not print the control group tree or journal entries. Use <command>status</command> if you
ec07c3c8
AK
130 are looking for formatted human-readable output.</para>
131
aefdc112 132 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
798d3a52
ZJS
133 </varlistentry>
134
135 <varlistentry>
1eecafb8 136 <term><command>start</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
137
138 <listitem><para>Start a container as a system service, using
139 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
140 This starts <filename>systemd-nspawn@.service</filename>,
141 instantiated for the specified machine name, similar to the
142 effect of <command>systemctl start</command> on the service
143 name. <command>systemd-nspawn</command> looks for a container
144 image by the specified name in
145 <filename>/var/lib/machines/</filename> (and other search
146 paths, see below) and runs it. Use
b938cb90 147 <command>list-images</command> (see below) for listing
798d3a52
ZJS
148 available container images to start.</para>
149
150 <para>Note that
151 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
152 also interfaces with a variety of other container and VM
153 managers, <command>systemd-nspawn</command> is just one
154 implementation of it. Most of the commands available in
155 <command>machinectl</command> may be used on containers or VMs
156 controlled by other managers, not just
157 <command>systemd-nspawn</command>. Starting VMs and container
158 images on those managers requires manager-specific
159 tools.</para>
160
161 <para>To interactively start a container on the command line
162 with full access to the container's console, please invoke
163 <command>systemd-nspawn</command> directly. To stop a running
ec07c3c8
AK
164 container use <command>machinectl poweroff</command>.</para>
165
aefdc112 166 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
167 </varlistentry>
168
169 <varlistentry>
91913f58 170 <term><command>login</command> [<replaceable>NAME</replaceable>]</term>
798d3a52 171
c454426c 172 <listitem><para>Open an interactive terminal login session in
b938cb90 173 a container or on the local host. If an argument is supplied,
91913f58
LP
174 it refers to the container machine to connect to. If none is
175 specified, or the container name is specified as the empty
176 string, or the special machine name <literal>.host</literal>
177 (see below) is specified, the connection is made to the local
178 host instead. This will create a TTY connection to a specific
179 container or the local host and asks for the execution of a
180 getty on it. Note that this is only supported for containers
181 running
798d3a52
ZJS
182 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
183 as init system.</para>
184
185 <para>This command will open a full login prompt on the
91913f58
LP
186 container or the local host, which then asks for username and
187 password. Use <command>shell</command> (see below) or
798d3a52 188 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
91913f58
LP
189 with the <option>--machine=</option> switch to directly invoke
190 a single command, either interactively or in the
ec07c3c8
AK
191 background.</para>
192
aefdc112 193 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
798d3a52
ZJS
194 </varlistentry>
195
c454426c 196 <varlistentry>
1eecafb8 197 <term><command>shell</command> [[<replaceable>NAME</replaceable>@]<replaceable>NAME</replaceable> [<replaceable>PATH</replaceable> [<replaceable>ARGUMENTS</replaceable>…]]] </term>
c454426c
LP
198
199 <listitem><para>Open an interactive shell session in a
91913f58
LP
200 container or on the local host. The first argument refers to
201 the container machine to connect to. If none is specified, or
202 the machine name is specified as the empty string, or the
203 special machine name <literal>.host</literal> (see below) is
204 specified, the connection is made to the local host
15102ced 205 instead. This works similarly to <command>login</command>, but
91913f58 206 immediately invokes a user process. This command runs the
c46bc7e2
SL
207 specified executable with the specified arguments, or the
208 default shell for the user if none is specified, or
209 <filename>/bin/sh</filename> if no default shell is found. By default,
ef3100e9
LP
210 <option>--uid=</option>, or by prefixing the machine name with
211 a username and an <literal>@</literal> character, a different
212 user may be selected. Use <option>--setenv=</option> to set
213 environment variables for the executed process.</para>
214
7f129a1f
LP
215 <para>Note that <command>machinectl shell</command> does not propagate the exit code/status of the invoked
216 shell process. Use <command>systemd-run</command> instead if that information is required (see below).</para>
217
15102ced
ZJS
218 <para>Using the <command>shell</command> command without arguments (thus invoking the executed shell
219 or command on the local host), is in many ways similar to a <citerefentry
220 project='die-net'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry> session,
221 but, unlike <command>su</command>, completely isolates the new session from the originating session,
222 so that it shares no process or session properties and is in a clean well-defined state. It will be
223 tracked in a new utmp, login, audit, security, and keyring sessions, and will not inherit any
224 environment variables or resource limits, among other properties.</para>
225
226 <para>Note that
227 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry> with
228 its <option>--machine=</option> switch may be used in place of the <command>machinectl
229 shell</command> command, and allows non-interactive operation, more detailed and low-level
230 configuration of the invoked unit, as well as access to runtime and exit code/status information of
231 the invoked shell process. In particular, use <command>systemd-run</command>'s
232 <option>--wait</option> switch to propagate exit status information of the invoked process. Use
233 <command>systemd-run</command>'s <option>--pty</option> switch to acquire an interactive shell,
234 similarly to <command>machinectl shell</command>. In general, <command>systemd-run</command> is
235 preferable for scripting purposes. However, note that <command>systemd-run</command> might require
ec07c3c8
AK
236 higher privileges than <command>machinectl shell</command>.</para>
237
aefdc112 238 <xi:include href="version-info.xml" xpointer="v225"/></listitem>
c454426c
LP
239 </varlistentry>
240
798d3a52 241 <varlistentry>
1eecafb8
ZJS
242 <term><command>enable</command> <replaceable>NAME</replaceable>…</term>
243 <term><command>disable</command> <replaceable>NAME</replaceable>…</term>
798d3a52 244
15102ced 245 <listitem><para>Enable or disable a container as a system service to start at system boot, using
798d3a52 246 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
15102ced
ZJS
247 This enables or disables <filename>systemd-nspawn@.service</filename>, instantiated for the specified
248 machine name, similarly to the effect of <command>systemctl enable</command> or <command>systemctl
c2434a61
MY
249 disable</command> on the service name.</para>
250
251 <para>This command implicitly reloads the system manager configuration after completing the operation.
252 Note that this command does not implicitly start or power off the containers that are being operated on.
ec07c3c8
AK
253 If this is desired, combine the command with the <option>--now</option> switch.</para>
254
aefdc112 255 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
256 </varlistentry>
257
258 <varlistentry>
1eecafb8 259 <term><command>poweroff</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
260
261 <listitem><para>Power off one or more containers. This will
262 trigger a reboot by sending SIGRTMIN+4 to the container's init
263 process, which causes systemd-compatible init systems to shut
b2bb19bb
CR
264 down cleanly. Use <command>stop</command> as alias for <command>poweroff</command>.
265 This operation does not work on containers that do not run a
798d3a52
ZJS
266 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
267 init system, such as sysvinit. Use
268 <command>terminate</command> (see below) to immediately
269 terminate a container or VM, without cleanly shutting it
ec07c3c8
AK
270 down.</para>
271
aefdc112 272 <xi:include href="version-info.xml" xpointer="v212"/></listitem>
798d3a52
ZJS
273 </varlistentry>
274
275 <varlistentry>
1eecafb8 276 <term><command>reboot</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
277
278 <listitem><para>Reboot one or more containers. This will
279 trigger a reboot by sending SIGINT to the container's init
280 process, which is roughly equivalent to pressing Ctrl+Alt+Del
281 on a non-containerized system, and is compatible with
ec07c3c8
AK
282 containers running any system manager.</para>
283
aefdc112 284 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
798d3a52
ZJS
285 </varlistentry>
286
287 <varlistentry>
1eecafb8 288 <term><command>terminate</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
289
290 <listitem><para>Immediately terminates a virtual machine or
291 container, without cleanly shutting it down. This kills all
292 processes of the virtual machine or container and deallocates
293 all resources attached to that instance. Use
294 <command>poweroff</command> to issue a clean shutdown
ec07c3c8
AK
295 request.</para>
296
aefdc112 297 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
798d3a52
ZJS
298 </varlistentry>
299
300 <varlistentry>
1eecafb8 301 <term><command>kill</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
302
303 <listitem><para>Send a signal to one or more processes of the
304 virtual machine or container. This means processes as seen by
305 the host, not the processes inside the virtual machine or
4ccde410 306 container. Use <option>--kill-whom=</option> to select which
798d3a52 307 process to kill. Use <option>--signal=</option> to select the
ec07c3c8
AK
308 signal to send.</para>
309
aefdc112 310 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
798d3a52
ZJS
311 </varlistentry>
312
313 <varlistentry>
314 <term><command>bind</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term>
315
d3590ace
LP
316 <listitem><para>Bind mounts a file or directory from the host into the specified container. The first path
317 argument is the source file or directory on the host, the second path argument is the destination file or
318 directory in the container. When the latter is omitted, the destination path in the container is the same as
319 the source path on the host. When combined with the <option>--read-only</option> switch, a ready-only bind
320 mount is created. When combined with the <option>--mkdir</option> switch, the destination path is first created
321 before the mount is applied. Note that this option is currently only supported for
7f43928b 322 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> containers,
d3590ace
LP
323 and only if user namespacing (<option>--private-users</option>) is not used. This command supports bind
324 mounting directories, regular files, device nodes, <constant>AF_UNIX</constant> socket nodes, as well as
ec07c3c8
AK
325 FIFOs.</para>
326
327 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
328 </varlistentry>
329
330 <varlistentry>
ae03e1a9 331 <term><command>copy-to</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>] <option>--force</option></term>
798d3a52
ZJS
332
333 <listitem><para>Copies files or directories from the host
334 system into a running container. Takes a container name,
335 followed by the source path on the host and the destination
b938cb90 336 path in the container. If the destination path is omitted, the
d01cd401 337 same as the source path is used.</para>
798d3a52 338
d01cd401
LP
339 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
340 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
ec07c3c8
AK
341 user and group (UID/GID 0).</para>
342
aefdc112 343 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
d01cd401 344 </varlistentry>
798d3a52
ZJS
345
346 <varlistentry>
ae03e1a9 347 <term><command>copy-from</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>] <option>--force</option></term>
798d3a52
ZJS
348
349 <listitem><para>Copies files or directories from a container
350 into the host system. Takes a container name, followed by the
e9dd6984 351 source path in the container and the destination path on the host.
b938cb90 352 If the destination path is omitted, the same as the source path
d01cd401
LP
353 is used.</para>
354
355 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
356 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
ec07c3c8
AK
357 user and group (UID/GID 0).</para>
358
aefdc112 359 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
360 </varlistentry>
361 </variablelist></refsect2>
362
363 <refsect2><title>Image Commands</title><variablelist>
364
365 <varlistentry>
366 <term><command>list-images</command></term>
367
368 <listitem><para>Show a list of locally installed container and
369 VM images. This enumerates all raw disk images and container
370 directories and subvolumes in
371 <filename>/var/lib/machines/</filename> (and other search
372 paths, see below). Use <command>start</command> (see above) to
b938cb90
JE
373 run a container off one of the listed images. Note that, by
374 default, containers whose name begins with a dot
798d3a52
ZJS
375 (<literal>.</literal>) are not shown. To show these too,
376 specify <option>--all</option>. Note that a special image
377 <literal>.host</literal> always implicitly exists and refers
ec07c3c8
AK
378 to the image the host itself is booted from.</para>
379
380 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
381 </varlistentry>
382
383 <varlistentry>
1eecafb8 384 <term><command>image-status</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52
ZJS
385
386 <listitem><para>Show terse status information about one or
387 more container or VM images. This function is intended to
388 generate human-readable output. Use
389 <command>show-image</command> (see below) to generate
ec07c3c8
AK
390 computer-parsable output instead.</para>
391
aefdc112 392 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
393 </varlistentry>
394
395 <varlistentry>
1eecafb8 396 <term><command>show-image</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52
ZJS
397
398 <listitem><para>Show properties of one or more registered
399 virtual machine or container images, or the manager itself. If
400 no argument is specified, properties of the manager will be
037a3ded 401 shown. If a NAME is specified, properties of this virtual
798d3a52
ZJS
402 machine or container image are shown. By default, empty
403 properties are suppressed. Use <option>--all</option> to show
404 those too. To select specific properties to show, use
405 <option>--property=</option>. This command is intended to be
406 used whenever computer-parsable output is required. Use
407 <command>image-status</command> if you are looking for
ec07c3c8
AK
408 formatted human-readable output.</para>
409
aefdc112 410 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
411 </varlistentry>
412
1ed35a0d
MY
413 <varlistentry>
414 <term><command>edit</command> <replaceable>NAME|FILE</replaceable></term>
415
bf63dadb
ZJS
416 <listitem><para>Edit the settings file of the specified machines. For the format of the settings
417 file, refer to
418 <citerefentry project='man-pages'><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
419 If an existing settings file of the given machine can't be found, <command>edit</command>
420 automatically create a new settings file from scratch under <filename>/etc/</filename>.
421 </para>
ec07c3c8
AK
422
423 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
1ed35a0d
MY
424 </varlistentry>
425
426 <varlistentry>
427 <term><command>cat</command> <replaceable>NAME|FILE</replaceable></term>
428
ec07c3c8
AK
429 <listitem><para>Show the settings file of the specified machines.</para>
430
431 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
1ed35a0d
MY
432 </varlistentry>
433
798d3a52
ZJS
434 <varlistentry>
435 <term><command>clone</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
436
d13febb1
LP
437 <listitem><para>Clones a container or VM image. The arguments specify the name of the image to clone and the
438 name of the newly cloned image. Note that plain directory container images are cloned into btrfs subvolume
439 images with this command, if the underlying file system supports this. Note that cloning a container or VM
17cbb288
LP
440 image is optimized for file systems that support copy-on-write, and might not be efficient on others, due to
441 file system limitations.</para>
3fe22bb4 442
38b38500 443 <para>Note that this command leaves hostname, machine ID and
3fe22bb4
LP
444 all other settings that could identify the instance
445 unmodified. The original image and the cloned copy will hence
446 share these credentials, and it might be necessary to manually
d94c2b06
LP
447 change them in the copy.</para>
448
449 <para>If combined with the <option>--read-only</option> switch a read-only cloned image is
ec07c3c8
AK
450 created.</para>
451
452 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
453 </varlistentry>
454
455 <varlistentry>
456 <term><command>rename</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
457
d6ce17c7 458 <listitem><para>Renames a container or VM image. The
798d3a52 459 arguments specify the name of the image to rename and the new
ec07c3c8
AK
460 name of the image.</para>
461
462 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
463 </varlistentry>
464
465 <varlistentry>
466 <term><command>read-only</command> <replaceable>NAME</replaceable> [<replaceable>BOOL</replaceable>]</term>
467
d6ce17c7 468 <listitem><para>Marks or (unmarks) a container or VM image
798d3a52
ZJS
469 read-only. Takes a VM or container image name, followed by a
470 boolean as arguments. If the boolean is omitted, positive is
ec07c3c8
AK
471 implied, i.e. the image is marked read-only.</para>
472
473 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
474 </varlistentry>
475
798d3a52 476 <varlistentry>
1eecafb8 477 <term><command>remove</command> <replaceable>NAME</replaceable>…</term>
798d3a52 478
d6ce17c7 479 <listitem><para>Removes one or more container or VM images.
798d3a52 480 The special image <literal>.host</literal>, which refers to
b938cb90 481 the host's own directory tree, may not be
ec07c3c8
AK
482 removed.</para>
483
aefdc112 484 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
485 </varlistentry>
486
d6ce17c7
LP
487 <varlistentry>
488 <term><command>set-limit</command> [<replaceable>NAME</replaceable>] <replaceable>BYTES</replaceable></term>
489
a8eaaee7 490 <listitem><para>Sets the maximum size in bytes that a specific
b938cb90 491 container or VM image, or all images, may grow up to on disk
7de30452 492 (disk quota). Takes either one or two parameters. The first,
d6ce17c7 493 optional parameter refers to a container or VM image name. If
b938cb90
JE
494 specified, the size limit of the specified image is changed. If
495 omitted, the overall size limit of the sum of all images stored
7de30452
LP
496 locally is changed. The final argument specifies the size
497 limit in bytes, possibly suffixed by the usual K, M, G, T
498 units. If the size limit shall be disabled, specify
499 <literal>-</literal> as size.</para>
500
ec07c3c8
AK
501 <para>Note that per-container size limits are only supported on btrfs file systems.</para>
502
503 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
d6ce17c7
LP
504 </varlistentry>
505
d94c2b06
LP
506 <varlistentry>
507 <term><command>clean</command></term>
508
509 <listitem><para>Remove hidden VM or container images (or all). This command removes all hidden machine images
3b121157 510 from <filename>/var/lib/machines/</filename>, i.e. those whose name begins with a dot. Use <command>machinectl
d94c2b06
LP
511 list-images --all</command> to see a list of all machine images, including the hidden ones.</para>
512
513 <para>When combined with the <option>--all</option> switch removes all images, not just hidden ones. This
3b121157 514 command effectively empties <filename>/var/lib/machines/</filename>.</para>
d94c2b06
LP
515
516 <para>Note that commands such as <command>machinectl pull-tar</command> or <command>machinectl
517 pull-raw</command> usually create hidden, read-only, unmodified machine images from the downloaded image first,
518 before cloning a writable working copy of it, in order to avoid duplicate downloads in case of images that are
519 reused multiple times. Use <command>machinectl clean</command> to remove old, hidden images created this
ec07c3c8
AK
520 way.</para>
521
522 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
d94c2b06
LP
523 </varlistentry>
524
798d3a52
ZJS
525 </variablelist></refsect2>
526
527 <refsect2><title>Image Transfer Commands</title><variablelist>
528
529 <varlistentry>
530 <term><command>pull-tar</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
531
532 <listitem><para>Downloads a <filename>.tar</filename>
533 container image from the specified URL, and makes it available
534 under the specified local machine name. The URL must be of
535 type <literal>http://</literal> or
536 <literal>https://</literal>, and must refer to a
537 <filename>.tar</filename>, <filename>.tar.gz</filename>,
538 <filename>.tar.xz</filename> or <filename>.tar.bz2</filename>
b938cb90 539 archive file. If the local machine name is omitted, it
798d3a52
ZJS
540 is automatically derived from the last component of the URL,
541 with its suffix removed.</para>
542
697be0be
TB
543 <para>The image is verified before it is made available, unless
544 <option>--verify=no</option> is specified.
545 Verification is done either via an inline signed file with the name
546 of the image and the suffix <filename>.sha256</filename> or via
547 separate <filename>SHA256SUMS</filename> and
548 <filename>SHA256SUMS.gpg</filename> files.
549 The signature files need to be made available on the same web
550 server, under the same URL as the <filename>.tar</filename> file.
551 With <option>--verify=checksum</option>, only the SHA256 checksum
552 for the file is verified, based on the <filename>.sha256</filename>
abdc57df 553 suffixed file or the <filename>SHA256SUMS</filename> file.
697be0be
TB
554 With <option>--verify=signature</option>, the sha checksum file is
555 first verified with the inline signature in the
556 <filename>.sha256</filename> file or the detached GPG signature file
557 <filename>SHA256SUMS.gpg</filename>.
558 The public key for this verification step needs to be available in
12b42c76
TG
559 <filename>/usr/lib/systemd/import-pubring.gpg</filename> or
560 <filename>/etc/systemd/import-pubring.gpg</filename>.</para>
798d3a52
ZJS
561
562 <para>The container image will be downloaded and stored in a
563 read-only subvolume in
b938cb90 564 <filename>/var/lib/machines/</filename> that is named after
798d3a52
ZJS
565 the specified URL and its HTTP etag. A writable snapshot is
566 then taken from this subvolume, and named after the specified
dd2b607b 567 local name. This behavior ensures that creating multiple
798d3a52
ZJS
568 container instances of the same URL is efficient, as multiple
569 downloads are not necessary. In order to create only the
570 read-only image, and avoid creating its writable snapshot,
571 specify <literal>-</literal> as local machine name.</para>
572
573 <para>Note that the read-only subvolume is prefixed with
6b94875f 574 <filename>.tar-</filename>, and is thus not shown by
798d3a52
ZJS
575 <command>list-images</command>, unless <option>--all</option>
576 is passed.</para>
577
578 <para>Note that pressing C-c during execution of this command
579 will not abort the download. Use
580 <command>cancel-transfer</command>, described
ec07c3c8
AK
581 below.</para>
582
583 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
584 </varlistentry>
585
586 <varlistentry>
587 <term><command>pull-raw</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
588
589 <listitem><para>Downloads a <filename>.raw</filename>
590 container or VM disk image from the specified URL, and makes
591 it available under the specified local machine name. The URL
592 must be of type <literal>http://</literal> or
593 <literal>https://</literal>. The container image must either
594 be a <filename>.qcow2</filename> or raw disk image, optionally
595 compressed as <filename>.gz</filename>,
596 <filename>.xz</filename>, or <filename>.bz2</filename>. If the
b938cb90 597 local machine name is omitted, it is automatically
798d3a52
ZJS
598 derived from the last component of the URL, with its suffix
599 removed.</para>
600
601 <para>Image verification is identical for raw and tar images
602 (see above).</para>
603
1d3eaa93 604 <para>If the downloaded image is in
6b94875f 605 <filename>.qcow2</filename> format it is converted into a raw
798d3a52
ZJS
606 image file before it is made available.</para>
607
608 <para>Downloaded images of this type will be placed as
609 read-only <filename>.raw</filename> file in
610 <filename>/var/lib/machines/</filename>. A local, writable
611 (reflinked) copy is then made under the specified local
612 machine name. To omit creation of the local, writable copy
613 pass <literal>-</literal> as local machine name.</para>
614
15102ced
ZJS
615 <para>Similarly to the behavior of <command>pull-tar</command>, the read-only image is prefixed with
616 <filename>.raw-</filename>, and thus not shown by <command>list-images</command>, unless
617 <option>--all</option> is passed.</para>
798d3a52
ZJS
618
619 <para>Note that pressing C-c during execution of this command
620 will not abort the download. Use
621 <command>cancel-transfer</command>, described
ec07c3c8
AK
622 below.</para>
623
624 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
625 </varlistentry>
626
af40e5d3
LP
627 <varlistentry>
628 <term><command>import-tar</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
629 <term><command>import-raw</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
630 <listitem><para>Imports a TAR or RAW container or VM image,
631 and places it under the specified name in
632 <filename>/var/lib/machines/</filename>. When
b938cb90 633 <command>import-tar</command> is used, the file specified as
a8eaaee7 634 the first argument should be a tar archive, possibly compressed
af40e5d3 635 with xz, gzip or bzip2. It will then be unpacked into its own
3b121157 636 subvolume in <filename>/var/lib/machines/</filename>. When
b938cb90 637 <command>import-raw</command> is used, the file should be a
af40e5d3
LP
638 qcow2 or raw disk image, possibly compressed with xz, gzip or
639 bzip2. If the second argument (the resulting image name) is
b938cb90 640 not specified, it is automatically derived from the file
1245e413 641 name. If the filename is passed as <literal>-</literal>, the
af40e5d3
LP
642 image is read from standard input, in which case the second
643 argument is mandatory.</para>
644
5f7ecd61
LP
645 <para>Optionally, the <option>--read-only</option> switch may be used to create a read-only container or VM
646 image. No cryptographic validation is done when importing the images.</para>
af40e5d3
LP
647
648 <para>Much like image downloads, ongoing imports may be listed
649 with <command>list-transfers</command> and aborted with
ec07c3c8
AK
650 <command>cancel-transfer</command>.</para>
651
652 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
af40e5d3
LP
653 </varlistentry>
654
1d7579c4
LP
655 <varlistentry>
656 <term><command>import-fs</command> <replaceable>DIRECTORY</replaceable> [<replaceable>NAME</replaceable>]</term>
657
658 <listitem><para>Imports a container image stored in a local directory into
15102ced
ZJS
659 <filename>/var/lib/machines/</filename>, operates similarly to <command>import-tar</command> or
660 <command>import-raw</command>, but the first argument is the source directory. If supported, this
ec07c3c8
AK
661 command will create a btrfs snapshot or subvolume for the new image.</para>
662
663 <xi:include href="version-info.xml" xpointer="v240"/></listitem>
1d7579c4
LP
664 </varlistentry>
665
6e9efa59
LP
666 <varlistentry>
667 <term><command>export-tar</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
668 <term><command>export-raw</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
669 <listitem><para>Exports a TAR or RAW container or VM image and
670 stores it in the specified file. The first parameter should be
671 a VM or container image name. The second parameter should be a
672 file path the TAR or RAW image is written to. If the path ends
b938cb90
JE
673 in <literal>.gz</literal>, the file is compressed with gzip, if
674 it ends in <literal>.xz</literal>, with xz, and if it ends in
675 <literal>.bz2</literal>, with bzip2. If the path ends in
676 neither, the file is left uncompressed. If the second argument
677 is missing, the image is written to standard output. The
6e9efa59
LP
678 compression may also be explicitly selected with the
679 <option>--format=</option> switch. This is in particular
680 useful if the second parameter is left unspecified.</para>
681
682 <para>Much like image downloads and imports, ongoing exports
683 may be listed with <command>list-transfers</command> and
684 aborted with
685 <command>cancel-transfer</command>.</para>
686
b938cb90 687 <para>Note that, currently, only directory and subvolume images
6e9efa59 688 may be exported as TAR images, and only raw disk images as RAW
ec07c3c8
AK
689 images.</para>
690
691 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
6e9efa59
LP
692 </varlistentry>
693
798d3a52
ZJS
694 <varlistentry>
695 <term><command>list-transfers</command></term>
696
697 <listitem><para>Shows a list of container or VM image
6e9efa59 698 downloads, imports and exports that are currently in
ec07c3c8
AK
699 progress.</para>
700
701 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
702 </varlistentry>
703
704 <varlistentry>
ee156e8d 705 <term><command>cancel-transfer</command> <replaceable>ID</replaceable>…</term>
798d3a52 706
6e9efa59
LP
707 <listitem><para>Aborts a download, import or export of the
708 container or VM image with the specified ID. To list ongoing
709 transfers and their IDs, use
ec07c3c8
AK
710 <command>list-transfers</command>. </para>
711
aefdc112 712 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
798d3a52
ZJS
713 </varlistentry>
714
715 </variablelist></refsect2>
716
717 </refsect1>
718
e1fac8a6
ZJS
719 <refsect1>
720 <title>Options</title>
721
722 <para>The following options are understood:</para>
723
724 <variablelist>
725 <varlistentry>
726 <term><option>-p</option></term>
727 <term><option>--property=</option></term>
728
729 <listitem><para>When showing machine or image properties,
730 limit the output to certain properties as specified by the
731 argument. If not specified, all set properties are shown. The
732 argument should be a property name, such as
733 <literal>Name</literal>. If specified more than once, all
734 properties with the specified names are
ec07c3c8
AK
735 shown.</para>
736
737 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
e1fac8a6
ZJS
738 </varlistentry>
739
740 <varlistentry>
741 <term><option>-a</option></term>
742 <term><option>--all</option></term>
743
744 <listitem><para>When showing machine or image properties, show
745 all properties regardless of whether they are set or
746 not.</para>
747
748 <para>When listing VM or container images, do not suppress
749 images beginning in a dot character
750 (<literal>.</literal>).</para>
751
ec07c3c8
AK
752 <para>When cleaning VM or container images, remove all images, not just hidden ones.</para>
753
754 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
e1fac8a6
ZJS
755 </varlistentry>
756
757 <varlistentry>
758 <term><option>--value</option></term>
759
760 <listitem><para>When printing properties with <command>show</command>, only print the value,
ec07c3c8
AK
761 and skip the property name and <literal>=</literal>.</para>
762
763 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
e1fac8a6
ZJS
764 </varlistentry>
765
766 <varlistentry>
767 <term><option>-l</option></term>
768 <term><option>--full</option></term>
769
12845a91
YW
770 <listitem><para>Do not ellipsize process tree entries or table. This implies
771 <option>--max-addresses=full</option>.</para>
ec07c3c8
AK
772
773 <xi:include href="version-info.xml" xpointer="v206"/>
e1fac8a6
ZJS
774 </listitem>
775 </varlistentry>
776
777 <varlistentry>
4ccde410 778 <term><option>--kill-whom=</option></term>
e1fac8a6
ZJS
779
780 <listitem><para>When used with <command>kill</command>, choose
781 which processes to kill. Must be one of
782 <option>leader</option>, or <option>all</option> to select
783 whether to kill only the leader process of the machine or all
784 processes of the machine. If omitted, defaults to
ec07c3c8
AK
785 <option>all</option>.</para>
786
aefdc112 787 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
e1fac8a6
ZJS
788 </varlistentry>
789
86beb213 790 <xi:include href="standard-options.xml" xpointer="signal" />
e1fac8a6
ZJS
791
792 <varlistentry>
793 <term><option>--uid=</option></term>
794
795 <listitem><para>When used with the <command>shell</command> command, chooses the user ID to
796 open the interactive shell session as. If the argument to the <command>shell</command>
797 command also specifies a user name, this option is ignored. If the name is not specified
798 in either way, <literal>root</literal> will be used by default. Note that this switch is
ec07c3c8
AK
799 not supported for the <command>login</command> command (see below).</para>
800
801 <xi:include href="version-info.xml" xpointer="v225"/></listitem>
e1fac8a6
ZJS
802 </varlistentry>
803
804 <varlistentry>
89bf86e0
ZJS
805 <term><option>-E <replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
806 <term><option>--setenv=<replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
807
808 <listitem><para>When used with the <command>shell</command> command, sets an environment variable for
809 the executed shell. This option may be used more than once to set multiple variables. When
810 <literal>=</literal> and <replaceable>VALUE</replaceable> are omitted, the value of the variable with
811 the same name in the program environment will be used.</para>
812
813 <para>Note that this option is not supported for the <command>login</command> command.
ec07c3c8
AK
814 </para>
815
aefdc112 816 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
e1fac8a6
ZJS
817 </varlistentry>
818
819 <varlistentry>
820 <term><option>--mkdir</option></term>
821
822 <listitem><para>When used with <command>bind</command>, creates the destination file or directory before
823 applying the bind mount. Note that even though the name of this option suggests that it is suitable only for
824 directories, this option also creates the destination file node to mount over if the object to mount is not
ec07c3c8
AK
825 a directory, but a regular file, device node, socket or FIFO.</para>
826
827 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
e1fac8a6
ZJS
828 </varlistentry>
829
830 <varlistentry>
831 <term><option>--read-only</option></term>
832
833 <listitem><para>When used with <command>bind</command>, creates a read-only bind mount.</para>
834
835 <para>When used with <command>clone</command>, <command>import-raw</command> or <command>import-tar</command> a
ec07c3c8
AK
836 read-only container or VM image is created.</para>
837
838 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
e1fac8a6
ZJS
839 </varlistentry>
840
841 <varlistentry>
842 <term><option>-n</option></term>
843 <term><option>--lines=</option></term>
844
845 <listitem><para>When used with <command>status</command>,
846 controls the number of journal lines to show, counting from
847 the most recent ones. Takes a positive integer argument.
848 Defaults to 10.</para>
ec07c3c8
AK
849
850 <xi:include href="version-info.xml" xpointer="v219"/>
e1fac8a6
ZJS
851 </listitem>
852 </varlistentry>
853
854 <varlistentry>
855 <term><option>-o</option></term>
856 <term><option>--output=</option></term>
857
858 <listitem><para>When used with <command>status</command>,
859 controls the formatting of the journal entries that are shown.
860 For the available choices, see
861 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
ec07c3c8
AK
862 Defaults to <literal>short</literal>.</para>
863
864 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
e1fac8a6
ZJS
865 </varlistentry>
866
867 <varlistentry>
868 <term><option>--verify=</option></term>
869
870 <listitem><para>When downloading a container or VM image,
871 specify whether the image shall be verified before it is made
872 available. Takes one of <literal>no</literal>,
873 <literal>checksum</literal> and <literal>signature</literal>.
874 If <literal>no</literal>, no verification is done. If
875 <literal>checksum</literal> is specified, the download is
876 checked for integrity after the transfer is complete, but no
877 signatures are verified. If <literal>signature</literal> is
878 specified, the checksum is verified and the image's signature
879 is checked against a local keyring of trustable vendors. It is
880 strongly recommended to set this option to
881 <literal>signature</literal> if the server and protocol
882 support this. Defaults to
ec07c3c8
AK
883 <literal>signature</literal>.</para>
884
885 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
e1fac8a6
ZJS
886 </varlistentry>
887
c2434a61
MY
888 <varlistentry>
889 <term><option>--now</option></term>
890
891 <listitem>
892 <para>When used with <command>enable</command> or <command>disable</command>,
893 the containers will also be started or powered off. The start or poweroff
894 operation is only carried out when the respective enable or disable
895 operation has been successful.</para>
ec07c3c8
AK
896
897 <xi:include href="version-info.xml" xpointer="v253"/>
c2434a61
MY
898 </listitem>
899 </varlistentry>
900
e1fac8a6
ZJS
901 <varlistentry>
902 <term><option>--force</option></term>
903
904 <listitem><para>When downloading a container or VM image, and
905 a local copy by the specified local machine name already
906 exists, delete it first and replace it by the newly downloaded
ec07c3c8
AK
907 image.</para>
908
909 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
e1fac8a6
ZJS
910 </varlistentry>
911
912 <varlistentry>
913 <term><option>--format=</option></term>
914
915 <listitem><para>When used with the <option>export-tar</option>
916 or <option>export-raw</option> commands, specifies the
917 compression format to use for the resulting file. Takes one of
918 <literal>uncompressed</literal>, <literal>xz</literal>,
919 <literal>gzip</literal>, <literal>bzip2</literal>. By default,
920 the format is determined automatically from the image file
ec07c3c8
AK
921 name passed.</para>
922
923 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
e1fac8a6
ZJS
924 </varlistentry>
925
926 <varlistentry>
927 <term><option>--max-addresses=</option></term>
928
99b8149a
ZJS
929 <listitem><para>When used with the <option>list-machines</option> command, limits the number of IP
930 addresses shown for every machine. Defaults to 1. All addresses can be requested with
931 <literal>all</literal>. If the limit is 0, the address column is not shown. Otherwise, if the machine
ec07c3c8
AK
932 has more addresses than shown, <literal>…</literal> follows the last address.</para>
933
934 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
e1fac8a6
ZJS
935 </varlistentry>
936
937 <varlistentry>
938 <term><option>-q</option></term>
939 <term><option>--quiet</option></term>
940
ec07c3c8
AK
941 <listitem><para>Suppresses additional informational output while running.</para>
942
943 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
e1fac8a6
ZJS
944 </varlistentry>
945
946 <xi:include href="user-system-options.xml" xpointer="host" />
947
948 <varlistentry>
949 <term><option>-M</option></term>
950 <term><option>--machine=</option></term>
951
952 <listitem><para>Connect to
953 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
954 running in a local container, to perform the specified operation within
ec07c3c8
AK
955 the container.</para>
956
957 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
e1fac8a6
ZJS
958 </varlistentry>
959
960 <xi:include href="standard-options.xml" xpointer="no-pager" />
961 <xi:include href="standard-options.xml" xpointer="no-legend" />
962 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
963 <xi:include href="standard-options.xml" xpointer="help" />
964 <xi:include href="standard-options.xml" xpointer="version" />
965 </variablelist>
966 </refsect1>
967
91913f58
LP
968 <refsect1>
969 <title>Machine and Image Names</title>
970
971 <para>The <command>machinectl</command> tool operates on machines
b938cb90 972 and images whose names must be chosen following strict
38b38500 973 rules. Machine names must be suitable for use as hostnames
91913f58
LP
974 following a conservative subset of DNS and UNIX/Linux
975 semantics. Specifically, they must consist of one or more
976 non-empty label strings, separated by dots. No leading or trailing
977 dots are allowed. No sequences of multiple dots are allowed. The
a8eaaee7 978 label strings may only consist of alphanumeric characters as well
91913f58
LP
979 as the dash and underscore. The maximum length of a machine name
980 is 64 characters.</para>
981
982 <para>A special machine with the name <literal>.host</literal>
983 refers to the running host system itself. This is useful for execution
a8eaaee7 984 operations or inspecting the host system as well. Note that
91913f58
LP
985 <command>machinectl list</command> will not show this special
986 machine unless the <option>--all</option> switch is specified.</para>
987
a8eaaee7 988 <para>Requirements on image names are less strict, however, they must be
91913f58
LP
989 valid UTF-8, must be suitable as file names (hence not be the
990 single or double dot, and not include a slash), and may not
991 contain control characters. Since many operations search for an
b938cb90 992 image by the name of a requested machine, it is recommended to name
91913f58
LP
993 images in the same strict fashion as machines.</para>
994
995 <para>A special image with the name <literal>.host</literal>
a8eaaee7 996 refers to the image of the running host system. It hence
91913f58
LP
997 conceptually maps to the special <literal>.host</literal> machine
998 name described above. Note that <command>machinectl
7ca41557 999 list-images</command> will not show this special image either, unless
91913f58
LP
1000 <option>--all</option> is specified.</para>
1001 </refsect1>
1002
798d3a52
ZJS
1003 <refsect1>
1004 <title>Files and Directories</title>
1005
1006 <para>Machine images are preferably stored in
1007 <filename>/var/lib/machines/</filename>, but are also searched for
1008 in <filename>/usr/local/lib/machines/</filename> and
b938cb90 1009 <filename>/usr/lib/machines/</filename>. For compatibility reasons,
798d3a52
ZJS
1010 the directory <filename>/var/lib/container/</filename> is
1011 searched, too. Note that images stored below
3b121157 1012 <filename>/usr/</filename> are always considered read-only. It is
798d3a52
ZJS
1013 possible to symlink machines images from other directories into
1014 <filename>/var/lib/machines/</filename> to make them available for
1015 control with <command>machinectl</command>.</para>
1016
5f7ecd61 1017 <para>Note that some image operations are only supported, efficient or atomic on btrfs file systems.</para>
7de30452 1018
798d3a52
ZJS
1019 <para>Disk images are understood by
1020 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1021 and <command>machinectl</command> in three formats:</para>
1022
1023 <itemizedlist>
1024 <listitem><para>A simple directory tree, containing the files
1025 and directories of the container to boot.</para></listitem>
1026
a8eaaee7 1027 <listitem><para>Subvolumes (on btrfs file systems), which are
798d3a52
ZJS
1028 similar to the simple directories, described above. However,
1029 they have additional benefits, such as efficient cloning and
1030 quota reporting.</para></listitem>
1031
1032 <listitem><para>"Raw" disk images, i.e. binary images of disks
1033 with a GPT or MBR partition table. Images of this type are
1034 regular files with the suffix
1035 <literal>.raw</literal>.</para></listitem>
1036 </itemizedlist>
1037
1038 <para>See
1039 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
a8eaaee7 1040 for more information on image formats, in particular its
798d3a52
ZJS
1041 <option>--directory=</option> and <option>--image=</option>
1042 options.</para>
1043 </refsect1>
1044
1045 <refsect1>
1046 <title>Examples</title>
1047 <example>
5bc9ea07 1048 <title>Download a Ubuntu image and open a shell in it</title>
798d3a52
ZJS
1049
1050 <programlisting># machinectl pull-tar https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.gz
e0ea94c1
LP
1051# systemd-nspawn -M trusty-server-cloudimg-amd64-root</programlisting>
1052
798d3a52
ZJS
1053 <para>This downloads and verifies the specified
1054 <filename>.tar</filename> image, and then uses
1055 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
1056 to open a shell in it.</para>
1057 </example>
1058
1059 <example>
1060 <title>Download a Fedora image, set a root password in it, start
5fadff33 1061 it as a service</title>
798d3a52 1062
5fadff33
ZJS
1063 <programlisting># machinectl pull-raw --verify=no \
1064 https://download.fedoraproject.org/pub/fedora/linux/releases/&fedora_latest_version;/Cloud/x86_64/images/Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86_64.raw.xz \
1065 Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
1066# systemd-nspawn -M Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
ac92ced5
BF
1067# passwd
1068# exit
5fadff33
ZJS
1069# machinectl start Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
1070# machinectl login Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64</programlisting>
798d3a52
ZJS
1071
1072 <para>This downloads the specified <filename>.raw</filename>
b938cb90 1073 image with verification disabled. Then, a shell is opened in it
798d3a52
ZJS
1074 and a root password is set. Afterwards the shell is left, and
1075 the machine started as system service. With the last command a
1076 login prompt into the container is requested.</para>
1077 </example>
1078
6e9efa59
LP
1079 <example>
1080 <title>Exports a container image as tar file</title>
1081
1082 <programlisting># machinectl export-tar fedora myfedora.tar.xz</programlisting>
1083
a8eaaee7
JE
1084 <para>Exports the container <literal>fedora</literal> as an
1085 xz-compressed tar file <filename>myfedora.tar.xz</filename> into the
6e9efa59
LP
1086 current directory.</para>
1087 </example>
1088
ef3100e9
LP
1089 <example>
1090 <title>Create a new shell session</title>
1091
1092 <programlisting># machinectl shell --uid=lennart</programlisting>
1093
b938cb90 1094 <para>This creates a new shell session on the local host for
ef3100e9
LP
1095 the user ID <literal>lennart</literal>, in a <citerefentry
1096 project='die-net'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry>-like
1097 fashion.</para>
1098 </example>
1099
798d3a52
ZJS
1100 </refsect1>
1101
1102 <refsect1>
1103 <title>Exit status</title>
1104
1105 <para>On success, 0 is returned, a non-zero failure code
1106 otherwise.</para>
1107 </refsect1>
1108
4ef3ca34 1109 <xi:include href="common-variables.xml" />
798d3a52
ZJS
1110
1111 <refsect1>
1112 <title>See Also</title>
1113 <para>
d47410f3 1114 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
798d3a52
ZJS
1115 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1116 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
6e9efa59 1117 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
16eb4024
ZJS
1118 <citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1119 <citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1120 <citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1121 <citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry>
798d3a52
ZJS
1122 </para>
1123 </refsect1>
19887cd0
ZJS
1124
1125</refentry>