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