Debian Codegraph @

man/machinectl.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM "custom-entities.ent" >
5 %entities;
6 ]>
7 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
8
9 <refentry id="machinectl" conditional='ENABLE_MACHINED'
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>machinectl</title>
14 <productname>systemd</productname>
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>
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
58 <listitem><para>The host system itself.</para></listitem>
59 </itemizedlist>
60
61 <para>Machines are identified by names that follow the same rules
62 as UNIX and DNS hostnames. For details, see below.</para>
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>
67
68 <itemizedlist>
69 <listitem><para>Directory trees containing an OS, including the
70 top-level directories <filename>/usr/</filename>,
71 <filename>/etc/</filename>, and so on.</para></listitem>
72
73 <listitem><para>btrfs subvolumes containing OS trees, similar to regular directory trees.</para></listitem>
74
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>
79
80 <listitem><para>The file system tree of the host OS itself.</para></listitem>
81 </itemizedlist>
82
83 <para>Images may be downloaded, imported and exported via the
84 <citerefentry><refentrytitle>importctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
85 tool.</para>
86 </refsect1>
87
88 <refsect1>
89 <title>Commands</title>
90
91 <para>The following commands are understood:</para>
92
93 <refsect2><title>Machine Commands</title>
94
95 <variablelist>
96 <varlistentry>
97 <term><command>list</command></term>
98
99 <listitem><para>List currently running (online) virtual
100 machines and containers. To enumerate machine images that can
101 be started, use <command>list-images</command> (see
102 below). Note that this command hides the special
103 <literal>.host</literal> machine by default. Use the
104 <option>--all</option> switch to show it.</para>
105
106 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
107 </varlistentry>
108
109 <varlistentry>
110 <term><command>status</command> <replaceable>NAME</replaceable>…</term>
111
112 <listitem><para>Show runtime status information about
113 one or more virtual machines and containers, followed by the
114 most recent log data from the journal. This function is
115 intended to generate human-readable output. If you are looking
116 for computer-parsable output, use <command>show</command>
117 instead. Note that the log data shown is reported by the
118 virtual machine or container manager, and frequently contains
119 console output of the machine, but not necessarily journal
120 contents of the machine itself.</para>
121
122 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
123 </varlistentry>
124
125 <varlistentry>
126 <term><command>show</command> [<replaceable>NAME</replaceable>…]</term>
127
128 <listitem><para>Show properties of one or more registered virtual machines or containers or the manager
129 itself. If no argument is specified, properties of the manager will be shown. If a NAME is specified,
130 properties of this virtual machine or container are shown. By default, empty properties are suppressed. Use
131 <option>--all</option> to show those too. To select specific properties to show, use
132 <option>--property=</option>. This command is intended to be used whenever computer-parsable output is
133 required, and does not print the control group tree or journal entries. Use <command>status</command> if you
134 are looking for formatted human-readable output.</para>
135
136 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
137 </varlistentry>
138
139 <varlistentry>
140 <term><command>start</command> <replaceable>NAME</replaceable>…</term>
141
142 <listitem><para>Start a container as a system service, using
143 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
144 This starts <filename>[email protected]</filename>,
145 instantiated for the specified machine name, similar to the
146 effect of <command>systemctl start</command> on the service
147 name. <command>systemd-nspawn</command> looks for a container
148 image by the specified name in
149 <filename>/var/lib/machines/</filename> (and other search
150 paths, see below) and runs it. Use
151 <command>list-images</command> (see below) for listing
152 available container images to start.</para>
153
154 <para>Note that
155 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
156 also interfaces with a variety of other container and VM
157 managers, <command>systemd-nspawn</command> is just one
158 implementation of it. Most of the commands available in
159 <command>machinectl</command> may be used on containers or VMs
160 controlled by other managers, not just
161 <command>systemd-nspawn</command>. Starting VMs and container
162 images on those managers requires manager-specific
163 tools.</para>
164
165 <para>To interactively start a container on the command line
166 with full access to the container's console, please invoke
167 <command>systemd-nspawn</command> directly. To stop a running
168 container use <command>machinectl poweroff</command>.</para>
169
170 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
171 </varlistentry>
172
173 <varlistentry>
174 <term><command>login</command> [<replaceable>NAME</replaceable>]</term>
175
176 <listitem><para>Open an interactive terminal login session in
177 a container or on the local host. If an argument is supplied,
178 it refers to the container machine to connect to. If none is
179 specified, or the container name is specified as the empty
180 string, or the special machine name <literal>.host</literal>
181 (see below) is specified, the connection is made to the local
182 host instead. This will create a TTY connection to a specific
183 container or the local host and asks for the execution of a
184 getty on it. Note that this is only supported for containers
185 running
186 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
187 as init system.</para>
188
189 <para>This command will open a full login prompt on the
190 container or the local host, which then asks for username and
191 password. Use <command>shell</command> (see below) or
192 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
193 with the <option>--machine=</option> switch to directly invoke
194 a single command, either interactively or in the
195 background.</para>
196
197 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
198 </varlistentry>
199
200 <varlistentry>
201 <term><command>shell</command> [[<replaceable>NAME</replaceable>@]<replaceable>NAME</replaceable> [<replaceable>PATH</replaceable> [<replaceable>ARGUMENTS</replaceable>…]]] </term>
202
203 <listitem><para>Open an interactive shell session in a
204 container or on the local host. The first argument refers to
205 the container machine to connect to. If none is specified, or
206 the machine name is specified as the empty string, or the
207 special machine name <literal>.host</literal> (see below) is
208 specified, the connection is made to the local host
209 instead. This works similarly to <command>login</command>, but
210 immediately invokes a user process. This command runs the
211 specified executable with the specified arguments, or the
212 default shell for the user if none is specified, or
213 <filename>/bin/sh</filename> if no default shell is found. By default,
214 <option>--uid=</option>, or by prefixing the machine name with
215 a username and an <literal>@</literal> character, a different
216 user may be selected. Use <option>--setenv=</option> to set
217 environment variables for the executed process.</para>
218
219 <para>Note that <command>machinectl shell</command> does not propagate the exit code/status of the invoked
220 shell process. Use <command>systemd-run</command> instead if that information is required (see below).</para>
221
222 <para>Using the <command>shell</command> command without arguments (thus invoking the executed shell
223 or command on the local host), is in many ways similar to a <citerefentry
224 project='die-net'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry> session,
225 but, unlike <command>su</command>, completely isolates the new session from the originating session,
226 so that it shares no process or session properties and is in a clean well-defined state. It will be
227 tracked in a new utmp, login, audit, security, and keyring sessions, and will not inherit any
228 environment variables or resource limits, among other properties.</para>
229
230 <para>Note that
231 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry> with
232 its <option>--machine=</option> switch may be used in place of the <command>machinectl
233 shell</command> command, and allows non-interactive operation, more detailed and low-level
234 configuration of the invoked unit, as well as access to runtime and exit code/status information of
235 the invoked shell process. In particular, use <command>systemd-run</command>'s
236 <option>--wait</option> switch to propagate exit status information of the invoked process. Use
237 <command>systemd-run</command>'s <option>--pty</option> switch to acquire an interactive shell,
238 similarly to <command>machinectl shell</command>. In general, <command>systemd-run</command> is
239 preferable for scripting purposes. However, note that <command>systemd-run</command> might require
240 higher privileges than <command>machinectl shell</command>.</para>
241
242 <xi:include href="version-info.xml" xpointer="v225"/></listitem>
243 </varlistentry>
244
245 <varlistentry>
246 <term><command>enable</command> <replaceable>NAME</replaceable>…</term>
247 <term><command>disable</command> <replaceable>NAME</replaceable>…</term>
248
249 <listitem><para>Enable or disable a container as a system service to start at system boot, using
250 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
251 This enables or disables <filename>[email protected]</filename>, instantiated for the specified
252 machine name, similarly to the effect of <command>systemctl enable</command> or <command>systemctl
253 disable</command> on the service name.</para>
254
255 <para>This command implicitly reloads the system manager configuration after completing the operation.
256 Note that this command does not implicitly start or power off the containers that are being operated on.
257 If this is desired, combine the command with the <option>--now</option> switch.</para>
258
259 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
260 </varlistentry>
261
262 <varlistentry>
263 <term><command>poweroff</command> <replaceable>NAME</replaceable>…</term>
264
265 <listitem><para>Power off one or more machines. For VMs managed by
266 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
267 this sends an ACPI powerdown request via QMP. For containers, this
268 sends SIGRTMIN+4 to the container's init process, which causes
269 systemd-compatible init systems to shut down cleanly. This
270 operation does not work on containers that do not run a
271 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
272 init system, such as sysvinit. Use
273 <command>stop</command> as alias for <command>poweroff</command>.
274 Use <command>terminate</command> (see below) to immediately
275 terminate a machine without cleanly shutting it down.</para>
276
277 <xi:include href="version-info.xml" xpointer="v212"/></listitem>
278 </varlistentry>
279
280 <varlistentry>
281 <term><command>reboot</command> <replaceable>NAME</replaceable>…</term>
282
283 <listitem><para>Reboot one or more machines. For VMs managed by
284 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
285 this sends a system reset request via QMP. For containers, this
286 sends SIGINT to the container's init process, which is roughly
287 equivalent to pressing Ctrl+Alt+Del on a non-containerized
288 system, and is compatible with containers running any system
289 manager. Use <command>restart</command> as alias for
290 <command>reboot</command>.</para>
291
292 <xi:include href="version-info.xml" xpointer="v209"/></listitem>
293 </varlistentry>
294
295 <varlistentry>
296 <term><command>pause</command> <replaceable>NAME</replaceable>…</term>
297
298 <listitem><para>Pause one or more machines. For VMs managed by
299 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
300 this freezes vCPU execution at the hypervisor level — the guest
301 operating system is not notified and does not observe an ACPI suspend.
302 From the guest's perspective time simply stops until the machine is
303 resumed with <command>resume</command>.</para>
304
305 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
306 </varlistentry>
307
308 <varlistentry>
309 <term><command>resume</command> <replaceable>NAME</replaceable>…</term>
310
311 <listitem><para>Resume one or more previously paused machines.
312 This restarts execution after a <command>pause</command>.</para>
313
314 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
315 </varlistentry>
316
317 <varlistentry>
318 <term><command>terminate</command> <replaceable>NAME</replaceable>…</term>
319
320 <listitem><para>Immediately terminates a virtual machine or
321 container, without cleanly shutting it down. This kills all
322 processes of the virtual machine or container and deallocates
323 all resources attached to that instance. Use
324 <command>poweroff</command> to issue a clean shutdown
325 request.</para>
326
327 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
328 </varlistentry>
329
330 <varlistentry>
331 <term><command>kill</command> <replaceable>NAME</replaceable>…</term>
332
333 <listitem><para>Send a signal to one or more processes of the
334 virtual machine or container. This means processes as seen by
335 the host, not the processes inside the virtual machine or
336 container. Use <option>--kill-whom=</option> to select which
337 process to kill. Use <option>--signal=</option> to select the
338 signal to send.</para>
339
340 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
341 </varlistentry>
342
343 <varlistentry>
344 <term><command>bind</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term>
345
346 <listitem><para>Bind mounts a file or directory from the host into the specified container. The first path
347 argument is the source file or directory on the host, the second path argument is the destination file or
348 directory in the container. When the latter is omitted, the destination path in the container is the same as
349 the source path on the host. When combined with the <option>--read-only</option> switch, a read-only bind
350 mount is created. When combined with the <option>--mkdir</option> switch, the destination path is first created
351 before the mount is applied. Note that this option is currently only supported for
352 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> containers,
353 and only if user namespacing (<option>--private-users</option>) is not used. This command supports bind
354 mounting directories, regular files, device nodes, <constant>AF_UNIX</constant> socket nodes, as well as
355 FIFOs.</para>
356
357 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
358 </varlistentry>
359
360 <varlistentry>
361 <term><command>bind-volume</command> <replaceable>NAME</replaceable> <replaceable>SPEC</replaceable></term>
362
363 <listitem><para>Acquire a storage volume from a
364 <citerefentry><refentrytitle>storagectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
365 provider and attach it to the running machine. <replaceable>SPEC</replaceable> is a string of the form
366 <literal><replaceable>PROVIDER</replaceable>:<replaceable>VOLUME</replaceable>[:<replaceable>CONFIG</replaceable>][:<replaceable>K=V</replaceable>,…]</literal>,
367 identical in grammar to the <option>--bind-volume=</option> argument of
368 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
369
370 <para>The attached volume is identified by the name <literal><replaceable>PROVIDER</replaceable>:<replaceable>VOLUME</replaceable></literal>
371 and may be detached at runtime via <command>unbind-volume</command>. Currently only supported for
372 <command>systemd-vmspawn</command> machines that expose an
373 <constant>io.systemd.MachineInstance</constant> control socket.</para>
374
375 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
376 </varlistentry>
377
378 <varlistentry>
379 <term><command>unbind-volume</command> <replaceable>NAME</replaceable> <replaceable>STORAGE-NAME</replaceable></term>
380
381 <listitem><para>Detach a storage volume from the running machine. <replaceable>STORAGE-NAME</replaceable>
382 is the <literal><replaceable>PROVIDER</replaceable>:<replaceable>VOLUME</replaceable></literal>
383 identifier that was specified at <command>bind-volume</command> time. Volumes that were attached at machine
384 startup (e.g. via <option>--bind-volume=</option> on
385 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>)
386 cannot be detached and will fail with
387 <constant>io.systemd.MachineInstance.StorageImmutable</constant>.</para>
388
389 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
390 </varlistentry>
391
392 <varlistentry>
393 <term><command>copy-to</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>] <option>--force</option></term>
394
395 <listitem><para>Copies files or directories from the host
396 system into a running container. Takes a container name,
397 followed by the source path on the host and the destination
398 path in the container. If the destination path is omitted, the
399 same as the source path is used.</para>
400
401 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
402 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
403 user and group (UID/GID 0).</para>
404
405 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
406 </varlistentry>
407
408 <varlistentry>
409 <term><command>copy-from</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>] <option>--force</option></term>
410
411 <listitem><para>Copies files or directories from a container
412 into the host system. Takes a container name, followed by the
413 source path in the container and the destination path on the host.
414 If the destination path is omitted, the same as the source path
415 is used.</para>
416
417 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
418 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
419 user and group (UID/GID 0).</para>
420
421 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
422 </varlistentry>
423 </variablelist></refsect2>
424
425 <refsect2><title>Image Commands</title>
426
427 <variablelist>
428 <varlistentry>
429 <term><command>list-images</command></term>
430
431 <listitem><para>Show a list of locally installed container and
432 VM images. This enumerates all raw disk images and container
433 directories and subvolumes in
434 <filename>/var/lib/machines/</filename> (and other search
435 paths, see below). Use <command>start</command> (see above) to
436 run a container off one of the listed images. Note that, by
437 default, containers whose name begins with a dot
438 (<literal>.</literal>) are not shown. To show these too,
439 specify <option>--all</option>. Note that a special image
440 <literal>.host</literal> always implicitly exists and refers
441 to the image the host itself is booted from.</para>
442
443 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
444 </varlistentry>
445
446 <varlistentry>
447 <term><command>image-status</command> [<replaceable>NAME</replaceable>…]</term>
448
449 <listitem><para>Show terse status information about one or
450 more container or VM images. This function is intended to
451 generate human-readable output. Use
452 <command>show-image</command> (see below) to generate
453 computer-parsable output instead.</para>
454
455 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
456 </varlistentry>
457
458 <varlistentry>
459 <term><command>show-image</command> [<replaceable>NAME</replaceable>…]</term>
460
461 <listitem><para>Show properties of one or more registered
462 virtual machine or container images, or the manager itself. If
463 no argument is specified, properties of the manager will be
464 shown. If a NAME is specified, properties of this virtual
465 machine or container image are shown. By default, empty
466 properties are suppressed. Use <option>--all</option> to show
467 those too. To select specific properties to show, use
468 <option>--property=</option>. This command is intended to be
469 used whenever computer-parsable output is required. Use
470 <command>image-status</command> if you are looking for
471 formatted human-readable output.</para>
472
473 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
474 </varlistentry>
475
476 <varlistentry>
477 <term><command>edit</command> <replaceable>NAME|FILE</replaceable></term>
478
479 <listitem><para>Edit the settings file of the specified machines. For the format of the settings
480 file, refer to
481 <citerefentry project='man-pages'><refentrytitle>systemd.nspawn</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
482 If an existing settings file of the given machine cannot be found, <command>edit</command>
483 automatically create a new settings file from scratch under
484 <filename>/etc/systemd/nspawn/</filename>.
485 </para>
486
487 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
488 </varlistentry>
489
490 <varlistentry>
491 <term><command>cat</command> <replaceable>NAME|FILE</replaceable></term>
492
493 <listitem><para>Show the settings file of the specified machines.</para>
494
495 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
496 </varlistentry>
497
498 <varlistentry>
499 <term><command>clone</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
500
501 <listitem><para>Clones a container or VM image. The arguments specify the name of the image to clone and the
502 name of the newly cloned image. Note that plain directory container images are cloned into btrfs subvolume
503 images with this command, if the underlying file system supports this. Note that cloning a container or VM
504 image is optimized for file systems that support copy-on-write, and might not be efficient on others, due to
505 file system limitations.</para>
506
507 <para>Note that this command leaves hostname, machine ID and
508 all other settings that could identify the instance
509 unmodified. The original image and the cloned copy will hence
510 share these credentials, and it might be necessary to manually
511 change them in the copy.</para>
512
513 <para>If combined with the <option>--read-only</option> switch a read-only cloned image is
514 created.</para>
515
516 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
517 </varlistentry>
518
519 <varlistentry>
520 <term><command>rename</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
521
522 <listitem><para>Renames a container or VM image. The
523 arguments specify the name of the image to rename and the new
524 name of the image.</para>
525
526 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
527 </varlistentry>
528
529 <varlistentry>
530 <term><command>read-only</command> <replaceable>NAME</replaceable> [<replaceable>BOOL</replaceable>]</term>
531
532 <listitem><para>Marks or (unmarks) a container or VM image
533 read-only. Takes a VM or container image name, followed by a
534 boolean as arguments. If the boolean is omitted, positive is
535 implied, i.e. the image is marked read-only.</para>
536
537 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
538 </varlistentry>
539
540 <varlistentry>
541 <term><command>remove</command> <replaceable>NAME</replaceable>…</term>
542
543 <listitem><para>Removes one or more container or VM images.
544 The special image <literal>.host</literal>, which refers to
545 the host's own directory tree, may not be
546 removed.</para>
547
548 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
549 </varlistentry>
550
551 <varlistentry>
552 <term><command>set-limit</command> [<replaceable>NAME</replaceable>] <replaceable>BYTES</replaceable></term>
553
554 <listitem><para>Sets the maximum size in bytes that a specific
555 container or VM image, or all images, may grow up to on disk
556 (disk quota). Takes either one or two parameters. The first,
557 optional parameter refers to a container or VM image name. If
558 specified, the size limit of the specified image is changed. If
559 omitted, the overall size limit of the sum of all images stored
560 locally is changed. The final argument specifies the size
561 limit in bytes, possibly suffixed by the usual K, M, G, T
562 units. If the size limit shall be disabled, specify
563 <literal>-</literal> as size.</para>
564
565 <para>Note that per-container size limits are only supported on btrfs file systems.</para>
566
567 <xi:include href="version-info.xml" xpointer="v220"/></listitem>
568 </varlistentry>
569
570 <varlistentry>
571 <term><command>clean</command></term>
572
573 <listitem><para>Remove hidden VM or container images (or all). This command removes all hidden machine images
574 from <filename>/var/lib/machines/</filename>, i.e. those whose name begins with a dot. Use <command>machinectl
575 list-images --all</command> to see a list of all machine images, including the hidden ones.</para>
576
577 <para>When combined with the <option>--all</option> switch removes all images, not just hidden ones. This
578 command effectively empties <filename>/var/lib/machines/</filename>.</para>
579
580 <para>Note that commands such as <command>importctl pull-tar</command> or <command>importctl
581 pull-raw</command> usually create hidden, read-only, unmodified machine images from the downloaded image first,
582 before cloning a writable working copy of it, in order to avoid duplicate downloads in case of images that are
583 reused multiple times. Use <command>machinectl clean</command> to remove old, hidden images created this
584 way.</para>
585
586 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
587 </varlistentry>
588
589 </variablelist></refsect2>
590 </refsect1>
591
592 <refsect1>
593 <title>Options</title>
594
595 <para>The following options are understood:</para>
596
597 <variablelist>
598 <varlistentry>
599 <term><option>-p</option></term>
600 <term><option>--property=</option></term>
601
602 <listitem><para>When showing machine or image properties,
603 limit the output to certain properties as specified by the
604 argument. If not specified, all set properties are shown. The
605 argument should be a property name, such as
606 <literal>Name</literal>. If specified more than once, all
607 properties with the specified names are
608 shown.</para>
609
610 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
611 </varlistentry>
612
613 <varlistentry>
614 <term><option>--value</option></term>
615
616 <listitem><para>When printing properties with <command>show</command>, only print the value,
617 and skip the property name and <literal>=</literal>.</para>
618
619 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
620 </varlistentry>
621
622 <xi:include href="timedatectl.xml" xpointer="option-P"/>
623
624 <varlistentry>
625 <term><option>-a</option></term>
626 <term><option>--all</option></term>
627
628 <listitem><para>When showing machine or image properties, show
629 all properties regardless of whether they are set or
630 not.</para>
631
632 <para>When listing VM or container images, do not suppress
633 images beginning in a dot character
634 (<literal>.</literal>).</para>
635
636 <para>When cleaning VM or container images, remove all images, not just hidden ones.</para>
637
638 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
639 </varlistentry>
640
641 <varlistentry>
642 <term><option>-l</option></term>
643 <term><option>--full</option></term>
644
645 <listitem><para>Do not ellipsize process tree entries or table. This implies
646 <option>--max-addresses=full</option>.</para>
647
648 <xi:include href="version-info.xml" xpointer="v206"/>
649 </listitem>
650 </varlistentry>
651
652 <varlistentry>
653 <term><option>--kill-whom=</option></term>
654
655 <listitem><para>When used with <command>kill</command>, choose which processes to kill. Must be one
656 of <option>leader</option>, <option>supervisor</option>, or <option>all</option> to select whether to
657 kill only the leader process of the machine, the supervisor process of the machine, or all processes
658 of the machine. If omitted, defaults to <option>all</option>.</para>
659
660 <xi:include href="version-info.xml" xpointer="v206"/></listitem>
661 </varlistentry>
662
663 <xi:include href="standard-options.xml" xpointer="signal" />
664
665 <varlistentry>
666 <term><option>--uid=</option></term>
667
668 <listitem><para>When used with the <command>shell</command> command, chooses the user ID to
669 open the interactive shell session as. If the argument to the <command>shell</command>
670 command also specifies a user name, this option is ignored. If the name is not specified
671 in either way, <literal>root</literal> will be used by default. Note that this switch is
672 not supported for the <command>login</command> command (see below).</para>
673
674 <xi:include href="version-info.xml" xpointer="v225"/></listitem>
675 </varlistentry>
676
677 <varlistentry>
678 <term><option>-E <replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
679 <term><option>--setenv=<replaceable>NAME</replaceable>[=<replaceable>VALUE</replaceable>]</option></term>
680
681 <listitem><para>When used with the <command>shell</command> command, sets an environment variable for
682 the executed shell. This option may be used more than once to set multiple variables. When
683 <literal>=</literal> and <replaceable>VALUE</replaceable> are omitted, the value of the variable with
684 the same name in the program environment will be used.</para>
685
686 <para>Note that this option is not supported for the <command>login</command> command.
687 </para>
688
689 <xi:include href="version-info.xml" xpointer="v230"/></listitem>
690 </varlistentry>
691
692 <varlistentry>
693 <term><option>--mkdir</option></term>
694
695 <listitem><para>When used with <command>bind</command>, creates the destination file or directory before
696 applying the bind mount. Note that even though the name of this option suggests that it is suitable only for
697 directories, this option also creates the destination file node to mount over if the object to mount is not
698 a directory, but a regular file, device node, socket or FIFO.</para>
699
700 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
701 </varlistentry>
702
703 <varlistentry>
704 <term><option>--read-only</option></term>
705
706 <listitem><para>When used with <command>bind</command>, creates a read-only bind mount.</para>
707
708 <para>When used with <command>clone</command> a read-only container or VM image is created.</para>
709
710 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
711 </varlistentry>
712
713 <varlistentry>
714 <term><option>-n</option></term>
715 <term><option>--lines=</option></term>
716
717 <listitem><para>When used with <command>status</command>,
718 controls the number of journal lines to show, counting from
719 the most recent ones. Takes a positive integer argument.
720 Defaults to 10.</para>
721
722 <xi:include href="version-info.xml" xpointer="v219"/>
723 </listitem>
724 </varlistentry>
725
726 <varlistentry>
727 <term><option>-o</option></term>
728 <term><option>--output=</option></term>
729
730 <listitem><para>When used with <command>status</command>,
731 controls the formatting of the journal entries that are shown.
732 For the available choices, see
733 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
734 Defaults to <literal>short</literal>.</para>
735
736 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
737 </varlistentry>
738
739 <varlistentry>
740 <term><option>--runner=</option><option>nspawn</option>|<option>vmspawn</option></term>
741
742 <listitem><para>When operating on machines choose whether to use
743 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
744 or
745 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
746 By default
747 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
748 is used.
749 </para>
750
751 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
752 </varlistentry>
753
754 <varlistentry>
755 <term><option>-V</option></term>
756
757 <listitem><para><option>-V</option> is a shorthand for <option>--runner=vmspawn</option>.</para>
758
759 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
760 </varlistentry>
761
762 <varlistentry>
763 <term><option>--now</option></term>
764
765 <listitem>
766 <para>When used with <command>enable</command> or <command>disable</command>,
767 the containers will also be started or powered off. The start or poweroff
768 operation is only carried out when the respective enable or disable
769 operation has been successful.</para>
770
771 <xi:include href="version-info.xml" xpointer="v253"/>
772 </listitem>
773 </varlistentry>
774
775 <varlistentry>
776 <term><option>--force</option></term>
777
778 <listitem><para>Replace target file when copying files.</para>
779
780 <xi:include href="version-info.xml" xpointer="v219"/></listitem>
781 </varlistentry>
782
783 <varlistentry>
784 <term><option>--max-addresses=</option></term>
785
786 <listitem><para>When used with the <option>list-machines</option> command, limits the number of IP
787 addresses shown for every machine. Defaults to 1. All addresses can be requested with
788 <literal>all</literal>. If the limit is 0, the address column is not shown. Otherwise, if the machine
789 has more addresses than shown, <literal>…</literal> follows the last address.</para>
790
791 <xi:include href="version-info.xml" xpointer="v232"/></listitem>
792 </varlistentry>
793
794 <varlistentry>
795 <term><option>-q</option></term>
796 <term><option>--quiet</option></term>
797
798 <listitem><para>Suppresses additional informational output while running.</para>
799
800 <xi:include href="version-info.xml" xpointer="v236"/></listitem>
801 </varlistentry>
802
803 <xi:include href="user-system-options.xml" xpointer="host" />
804
805 <varlistentry>
806 <term><option>-M</option></term>
807 <term><option>--machine=</option></term>
808
809 <listitem><para>Connect to
810 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
811 running in a local container, to perform the specified operation within
812 the container.</para>
813
814 <xi:include href="version-info.xml" xpointer="v235"/></listitem>
815 </varlistentry>
816
817 <xi:include href="standard-options.xml" xpointer="no-pager" />
818 <xi:include href="standard-options.xml" xpointer="no-legend" />
819 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
820 <xi:include href="standard-options.xml" xpointer="help" />
821 <xi:include href="standard-options.xml" xpointer="version" />
822 </variablelist>
823 </refsect1>
824
825 <refsect1>
826 <title>Machine and Image Names</title>
827
828 <para>The <command>machinectl</command> tool operates on machines
829 and images whose names must be chosen following strict
830 rules. Machine names must be suitable for use as hostnames
831 following a conservative subset of DNS and UNIX/Linux
832 semantics. Specifically, they must consist of one or more
833 non-empty label strings, separated by dots. No leading or trailing
834 dots are allowed. No sequences of multiple dots are allowed. The
835 label strings may only consist of alphanumeric characters as well
836 as the dash. The maximum length of a machine name is 64 characters.</para>
837
838 <para>A special machine with the name <literal>.host</literal>
839 refers to the running host system itself. This is useful for execution
840 operations or inspecting the host system as well. Note that
841 <command>machinectl list</command> will not show this special
842 machine unless the <option>--all</option> switch is specified.</para>
843
844 <para>Requirements on image names are less strict, however, they must be
845 valid UTF-8, must be suitable as file names (hence not be the
846 single or double dot, and not include a slash), and may not
847 contain control characters. Since many operations search for an
848 image by the name of a requested machine, it is recommended to name
849 images in the same strict fashion as machines.</para>
850
851 <para>A special image with the name <literal>.host</literal>
852 refers to the image of the running host system. It hence
853 conceptually maps to the special <literal>.host</literal> machine
854 name described above. Note that <command>machinectl
855 list-images</command> will not show this special image either, unless
856 <option>--all</option> is specified.</para>
857 </refsect1>
858
859 <refsect1>
860 <title>Files and Directories</title>
861
862 <para>Machine images are preferably stored in
863 <filename>/var/lib/machines/</filename>, but are also searched for
864 in <filename>/usr/local/lib/machines/</filename> and
865 <filename>/usr/lib/machines/</filename>. For compatibility reasons,
866 the directory <filename>/var/lib/container/</filename> is
867 searched, too. Note that images stored below
868 <filename>/usr/</filename> are always considered read-only. It is
869 possible to symlink machines images from other directories into
870 <filename>/var/lib/machines/</filename> to make them available for
871 control with <command>machinectl</command>.</para>
872
873 <para>Note that some image operations are only supported, efficient or atomic on btrfs file systems.</para>
874
875 <para>Disk images are understood by
876 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
877 and <command>machinectl</command> in three formats:</para>
878
879 <itemizedlist>
880 <listitem><para>A simple directory tree, containing the files
881 and directories of the container to boot.</para></listitem>
882
883 <listitem><para>Subvolumes (on btrfs file systems), which are
884 similar to the simple directories, described above. However,
885 they have additional benefits, such as efficient cloning and
886 quota reporting.</para></listitem>
887
888 <listitem><para>"Raw" disk images, i.e. binary images of disks
889 with a GPT or MBR partition table. Images of this type are
890 regular files with the suffix
891 <literal>.raw</literal>.</para></listitem>
892 </itemizedlist>
893
894 <para>See
895 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
896 for more information on image formats, in particular its
897 <option>--directory=</option> and <option>--image=</option>
898 options.</para>
899 </refsect1>
900
901 <refsect1>
902 <title>Examples</title>
903
904 <xi:include href="importctl.xml" xpointer="example-import-raw" />
905
906 </refsect1>
907
908 <refsect1>
909 <title>Exit status</title>
910
911 <para>On success, 0 is returned, a non-zero failure code
912 otherwise.</para>
913 </refsect1>
914
915 <xi:include href="common-variables.xml" />
916
917 <refsect1>
918 <title>See Also</title>
919 <para><simplelist type="inline">
920 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
921 <member><citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
922 <member><citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
923 <member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
924 <member><citerefentry><refentrytitle>importctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
925 <member><citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
926 <member><citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
927 <member><citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
928 <member><citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
929 <member><citerefentry project='die-net'><refentrytitle>zstd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
930 </simplelist></para>
931 </refsect1>
932
933 </refentry>