]>
Commit | Line | Data |
---|---|---|
14228c0d MB |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
e735f4d4 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> |
14228c0d MB |
4 | |
5 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2013 Zbigniew Jędrzejewski-Szmek | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | --> | |
23 | ||
60f067b4 | 24 | <refentry id="machinectl" conditional='ENABLE_MACHINED' |
e735f4d4 MP |
25 | xmlns:xi="http://www.w3.org/2001/XInclude"> |
26 | ||
27 | <refentryinfo> | |
28 | <title>machinectl</title> | |
29 | <productname>systemd</productname> | |
30 | ||
31 | <authorgroup> | |
32 | <author> | |
33 | <contrib>Developer</contrib> | |
34 | <firstname>Lennart</firstname> | |
35 | <surname>Poettering</surname> | |
36 | <email>lennart@poettering.net</email> | |
37 | </author> | |
38 | </authorgroup> | |
39 | </refentryinfo> | |
40 | ||
41 | <refmeta> | |
42 | <refentrytitle>machinectl</refentrytitle> | |
43 | <manvolnum>1</manvolnum> | |
44 | </refmeta> | |
45 | ||
46 | <refnamediv> | |
47 | <refname>machinectl</refname> | |
48 | <refpurpose>Control the systemd machine manager</refpurpose> | |
49 | </refnamediv> | |
50 | ||
51 | <refsynopsisdiv> | |
52 | <cmdsynopsis> | |
53 | <command>machinectl</command> | |
54 | <arg choice="opt" rep="repeat">OPTIONS</arg> | |
55 | <arg choice="req">COMMAND</arg> | |
56 | <arg choice="opt" rep="repeat">NAME</arg> | |
57 | </cmdsynopsis> | |
58 | </refsynopsisdiv> | |
59 | ||
60 | <refsect1> | |
61 | <title>Description</title> | |
62 | ||
63 | <para><command>machinectl</command> may be used to introspect and | |
64 | control the state of the | |
65 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
66 | virtual machine and container registration manager | |
67 | <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para> | |
68 | </refsect1> | |
69 | ||
70 | <refsect1> | |
71 | <title>Options</title> | |
72 | ||
73 | <para>The following options are understood:</para> | |
74 | ||
75 | <variablelist> | |
76 | <varlistentry> | |
77 | <term><option>-p</option></term> | |
78 | <term><option>--property=</option></term> | |
79 | ||
80 | <listitem><para>When showing machine or image properties, | |
81 | limit the output to certain properties as specified by the | |
82 | argument. If not specified, all set properties are shown. The | |
83 | argument should be a property name, such as | |
84 | <literal>Name</literal>. If specified more than once, all | |
85 | properties with the specified names are | |
86 | shown.</para></listitem> | |
87 | </varlistentry> | |
88 | ||
89 | <varlistentry> | |
90 | <term><option>-a</option></term> | |
91 | <term><option>--all</option></term> | |
92 | ||
93 | <listitem><para>When showing machine or image properties, show | |
94 | all properties regardless of whether they are set or | |
95 | not.</para> | |
96 | ||
97 | <para>When listing VM or container images, do not suppress | |
98 | images beginning in a dot character | |
99 | (<literal>.</literal>).</para></listitem> | |
100 | </varlistentry> | |
101 | ||
102 | <varlistentry> | |
103 | <term><option>-l</option></term> | |
104 | <term><option>--full</option></term> | |
105 | ||
106 | <listitem><para>Do not ellipsize process tree entries.</para> | |
107 | </listitem> | |
108 | </varlistentry> | |
109 | ||
110 | <varlistentry> | |
111 | <term><option>--no-ask-password</option></term> | |
112 | ||
113 | <listitem><para>Do not query the user for authentication for | |
114 | privileged operations.</para></listitem> | |
115 | </varlistentry> | |
116 | ||
117 | <varlistentry> | |
118 | <term><option>--kill-who=</option></term> | |
119 | ||
120 | <listitem><para>When used with <command>kill</command>, choose | |
121 | which processes to kill. Must be one of | |
122 | <option>leader</option>, or <option>all</option> to select | |
123 | whether to kill only the leader process of the machine or all | |
124 | processes of the machine. If omitted, defaults to | |
125 | <option>all</option>.</para></listitem> | |
126 | </varlistentry> | |
127 | ||
128 | <varlistentry> | |
129 | <term><option>-s</option></term> | |
130 | <term><option>--signal=</option></term> | |
131 | ||
132 | <listitem><para>When used with <command>kill</command>, choose | |
133 | which signal to send to selected processes. Must be one of the | |
134 | well-known signal specifiers, such as | |
135 | <constant>SIGTERM</constant>, <constant>SIGINT</constant> or | |
136 | <constant>SIGSTOP</constant>. If omitted, defaults to | |
137 | <constant>SIGTERM</constant>.</para></listitem> | |
138 | </varlistentry> | |
139 | ||
140 | <varlistentry> | |
141 | <term><option>--mkdir</option></term> | |
142 | ||
143 | <listitem><para>When used with <command>bind</command> creates | |
144 | the destination directory before applying the bind | |
145 | mount.</para></listitem> | |
146 | </varlistentry> | |
147 | ||
148 | ||
149 | <varlistentry> | |
150 | <term><option>--read-only</option></term> | |
151 | ||
152 | <listitem><para>When used with <command>bind</command> applies | |
153 | a read-only bind mount.</para></listitem> | |
154 | </varlistentry> | |
155 | ||
156 | ||
157 | <varlistentry> | |
158 | <term><option>-n</option></term> | |
159 | <term><option>--lines=</option></term> | |
160 | ||
161 | <listitem><para>When used with <command>status</command>, | |
162 | controls the number of journal lines to show, counting from | |
163 | the most recent ones. Takes a positive integer argument. | |
164 | Defaults to 10.</para> | |
165 | </listitem> | |
166 | </varlistentry> | |
167 | ||
168 | <varlistentry> | |
169 | <term><option>-o</option></term> | |
170 | <term><option>--output=</option></term> | |
171 | ||
172 | <listitem><para>When used with <command>status</command>, | |
173 | controls the formatting of the journal entries that are shown. | |
174 | For the available choices, see | |
175 | <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
176 | Defaults to <literal>short</literal>.</para></listitem> | |
177 | </varlistentry> | |
178 | ||
179 | <varlistentry> | |
180 | <term><option>--verify=</option></term> | |
181 | ||
182 | <listitem><para>When downloading a container or VM image, | |
183 | specify whether the image shall be verified before it is made | |
184 | available. Takes one of <literal>no</literal>, | |
185 | <literal>checksum</literal> and <literal>signature</literal>. | |
186 | If <literal>no</literal> no verification is done. If | |
187 | <literal>checksum</literal> is specified the download is | |
188 | checked for integrity after transfer is complete, but no | |
189 | signatures are verified. If <literal>signature</literal> is | |
190 | specified, the checksum is verified and the images's signature | |
191 | is checked against a local keyring of trustable vendors. It is | |
192 | strongly recommended to set this option to | |
193 | <literal>signature</literal> if the server and protocol | |
194 | support this. Defaults to | |
195 | <literal>signature</literal>.</para></listitem> | |
196 | </varlistentry> | |
197 | ||
198 | <varlistentry> | |
199 | <term><option>--force</option></term> | |
200 | ||
201 | <listitem><para>When downloading a container or VM image, and | |
202 | a local copy by the specified local machine name already | |
203 | exists, delete it first and replace it by the newly downloaded | |
204 | image.</para></listitem> | |
205 | </varlistentry> | |
206 | ||
207 | <varlistentry> | |
208 | <term><option>--dkr-index-url</option></term> | |
209 | ||
210 | <listitem><para>Specifies the index server to use for | |
211 | downloading <literal>dkr</literal> images with the | |
212 | <command>pull-dkr</command>. Takes a | |
213 | <literal>http://</literal>, <literal>https://</literal> | |
214 | URL.</para></listitem> | |
215 | </varlistentry> | |
216 | ||
e3bff60a MP |
217 | <varlistentry> |
218 | <term><option>--format=</option></term> | |
219 | ||
220 | <listitem><para>When used with the <option>export-tar</option> | |
221 | or <option>export-raw</option> commands specifies the | |
222 | compression format to use for the resulting file. Takes one of | |
223 | <literal>uncompressed</literal>, <literal>xz</literal>, | |
224 | <literal>gzip</literal>, <literal>bzip2</literal>. By default | |
225 | the format is determined automatically from the image file | |
226 | name passed.</para></listitem> | |
227 | </varlistentry> | |
228 | ||
e735f4d4 MP |
229 | <xi:include href="user-system-options.xml" xpointer="host" /> |
230 | <xi:include href="user-system-options.xml" xpointer="machine" /> | |
231 | ||
232 | <xi:include href="standard-options.xml" xpointer="no-pager" /> | |
233 | <xi:include href="standard-options.xml" xpointer="no-legend" /> | |
234 | <xi:include href="standard-options.xml" xpointer="help" /> | |
235 | <xi:include href="standard-options.xml" xpointer="version" /> | |
236 | </variablelist> | |
237 | </refsect1> | |
238 | ||
239 | <refsect1> | |
240 | <title>Commands</title> | |
241 | ||
242 | <para>The following commands are understood:</para> | |
243 | ||
244 | <refsect2><title>Machine Commands</title><variablelist> | |
245 | ||
246 | <varlistentry> | |
247 | <term><command>list</command></term> | |
248 | ||
249 | <listitem><para>List currently running (online) virtual | |
250 | machines and containers. To enumerate container images that | |
251 | can be started, use <command>list-images</command> (see | |
252 | below).</para></listitem> | |
253 | </varlistentry> | |
254 | ||
255 | <varlistentry> | |
256 | <term><command>status</command> <replaceable>NAME</replaceable>...</term> | |
257 | ||
258 | <listitem><para>Show terse runtime status information about | |
259 | one or more virtual machines and containers, followed by the | |
260 | most recent log data from the journal. This function is | |
261 | intended to generate human-readable output. If you are looking | |
262 | for computer-parsable output, use <command>show</command> | |
263 | instead. Note that the log data shown is reported by the | |
264 | virtual machine or container manager, and frequently contains | |
265 | console output of the machine, but not necessarily journal | |
266 | contents of the machine itself.</para></listitem> | |
267 | </varlistentry> | |
268 | ||
269 | <varlistentry> | |
270 | <term><command>show</command> <replaceable>NAME</replaceable>...</term> | |
271 | ||
272 | <listitem><para>Show properties of one or more registered | |
273 | virtual machines or containers or the manager itself. If no | |
274 | argument is specified, properties of the manager will be | |
275 | shown. If an NAME is specified, properties of this virtual | |
276 | machine or container are shown. By default, empty properties | |
277 | are suppressed. Use <option>--all</option> to show those too. | |
278 | To select specific properties to show, use | |
279 | <option>--property=</option>. This command is intended to be | |
280 | used whenever computer-parsable output is required. Use | |
281 | <command>status</command> if you are looking for formatted | |
282 | human-readable output.</para></listitem> | |
283 | </varlistentry> | |
284 | ||
285 | <varlistentry> | |
286 | <term><command>start</command> <replaceable>NAME</replaceable>...</term> | |
287 | ||
288 | <listitem><para>Start a container as a system service, using | |
289 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
290 | This starts <filename>systemd-nspawn@.service</filename>, | |
291 | instantiated for the specified machine name, similar to the | |
292 | effect of <command>systemctl start</command> on the service | |
293 | name. <command>systemd-nspawn</command> looks for a container | |
294 | image by the specified name in | |
295 | <filename>/var/lib/machines/</filename> (and other search | |
296 | paths, see below) and runs it. Use | |
297 | <command>list-images</command> (see below), for listing | |
298 | available container images to start.</para> | |
299 | ||
300 | <para>Note that | |
301 | <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
302 | also interfaces with a variety of other container and VM | |
303 | managers, <command>systemd-nspawn</command> is just one | |
304 | implementation of it. Most of the commands available in | |
305 | <command>machinectl</command> may be used on containers or VMs | |
306 | controlled by other managers, not just | |
307 | <command>systemd-nspawn</command>. Starting VMs and container | |
308 | images on those managers requires manager-specific | |
309 | tools.</para> | |
310 | ||
311 | <para>To interactively start a container on the command line | |
312 | with full access to the container's console, please invoke | |
313 | <command>systemd-nspawn</command> directly. To stop a running | |
314 | container use <command>machinectl poweroff</command>, see | |
315 | below.</para></listitem> | |
316 | </varlistentry> | |
317 | ||
318 | <varlistentry> | |
319 | <term><command>login</command> <replaceable>NAME</replaceable></term> | |
320 | ||
321 | <listitem><para>Open an interactive terminal login session to | |
322 | a container. This will create a TTY connection to a specific | |
323 | container and asks for the execution of a getty on it. Note | |
324 | that this is only supported for containers running | |
325 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
326 | as init system.</para> | |
327 | ||
328 | <para>This command will open a full login prompt on the | |
329 | container, which then asks for username and password. Use | |
330 | <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
331 | with the <option>--machine=</option> switch to invoke a single | |
332 | command, either interactively or in the background within a | |
333 | local container.</para></listitem> | |
334 | </varlistentry> | |
335 | ||
336 | <varlistentry> | |
337 | <term><command>enable</command> <replaceable>NAME</replaceable>...</term> | |
338 | <term><command>disable</command> <replaceable>NAME</replaceable>...</term> | |
339 | ||
340 | <listitem><para>Enable or disable a container as a system | |
341 | service to start at system boot, using | |
342 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
343 | This enables or disables | |
344 | <filename>systemd-nspawn@.service</filename>, instantiated for | |
345 | the specified machine name, similar to the effect of | |
346 | <command>systemctl enable</command> or <command>systemctl | |
347 | disable</command> on the service name.</para></listitem> | |
348 | </varlistentry> | |
349 | ||
350 | <varlistentry> | |
351 | <term><command>poweroff</command> <replaceable>NAME</replaceable>...</term> | |
352 | ||
353 | <listitem><para>Power off one or more containers. This will | |
354 | trigger a reboot by sending SIGRTMIN+4 to the container's init | |
355 | process, which causes systemd-compatible init systems to shut | |
356 | down cleanly. This operation does not work on containers that | |
357 | do not run a | |
358 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible | |
359 | init system, such as sysvinit. Use | |
360 | <command>terminate</command> (see below) to immediately | |
361 | terminate a container or VM, without cleanly shutting it | |
362 | down.</para></listitem> | |
363 | </varlistentry> | |
364 | ||
365 | <varlistentry> | |
366 | <term><command>reboot</command> <replaceable>NAME</replaceable>...</term> | |
367 | ||
368 | <listitem><para>Reboot one or more containers. This will | |
369 | trigger a reboot by sending SIGINT to the container's init | |
370 | process, which is roughly equivalent to pressing Ctrl+Alt+Del | |
371 | on a non-containerized system, and is compatible with | |
372 | containers running any system manager.</para></listitem> | |
373 | </varlistentry> | |
374 | ||
375 | <varlistentry> | |
376 | <term><command>terminate</command> <replaceable>NAME</replaceable>...</term> | |
377 | ||
378 | <listitem><para>Immediately terminates a virtual machine or | |
379 | container, without cleanly shutting it down. This kills all | |
380 | processes of the virtual machine or container and deallocates | |
381 | all resources attached to that instance. Use | |
382 | <command>poweroff</command> to issue a clean shutdown | |
383 | request.</para></listitem> | |
384 | </varlistentry> | |
385 | ||
386 | <varlistentry> | |
387 | <term><command>kill</command> <replaceable>NAME</replaceable>...</term> | |
388 | ||
389 | <listitem><para>Send a signal to one or more processes of the | |
390 | virtual machine or container. This means processes as seen by | |
391 | the host, not the processes inside the virtual machine or | |
392 | container. Use <option>--kill-who=</option> to select which | |
393 | process to kill. Use <option>--signal=</option> to select the | |
394 | signal to send.</para></listitem> | |
395 | </varlistentry> | |
396 | ||
397 | <varlistentry> | |
398 | <term><command>bind</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term> | |
399 | ||
400 | <listitem><para>Bind mounts a directory from the host into the | |
401 | specified container. The first directory argument is the | |
402 | source directory on the host, the second directory argument | |
fb183854 MP |
403 | is the destination directory in the container. When the |
404 | latter is omitted the destination path in the container is | |
405 | the same as the source path on the host. When combined with | |
406 | the <option>--read-only</option> switch a ready-only bind | |
407 | mount is created. When combined with the | |
408 | <option>--mkdir</option> switch the destination path is first | |
409 | created before the mount is applied. Note that this option is | |
410 | currently only supported for | |
e735f4d4 MP |
411 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
412 | containers.</para></listitem> | |
413 | </varlistentry> | |
414 | ||
415 | <varlistentry> | |
416 | <term><command>copy-to</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term> | |
417 | ||
418 | <listitem><para>Copies files or directories from the host | |
419 | system into a running container. Takes a container name, | |
420 | followed by the source path on the host and the destination | |
421 | path in the container. If the destination path is omitted the | |
422 | same as the source path is used.</para></listitem> | |
423 | </varlistentry> | |
424 | ||
425 | ||
426 | <varlistentry> | |
427 | <term><command>copy-from</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term> | |
428 | ||
429 | <listitem><para>Copies files or directories from a container | |
430 | into the host system. Takes a container name, followed by the | |
431 | source path in the container the destination path on the host. | |
432 | If the destination path is omitted the same as the source path | |
433 | is used.</para></listitem> | |
434 | </varlistentry> | |
435 | </variablelist></refsect2> | |
436 | ||
437 | <refsect2><title>Image Commands</title><variablelist> | |
438 | ||
439 | <varlistentry> | |
440 | <term><command>list-images</command></term> | |
441 | ||
442 | <listitem><para>Show a list of locally installed container and | |
443 | VM images. This enumerates all raw disk images and container | |
444 | directories and subvolumes in | |
445 | <filename>/var/lib/machines/</filename> (and other search | |
446 | paths, see below). Use <command>start</command> (see above) to | |
447 | run a container off one of the listed images. Note that by | |
448 | default containers whose name begins with a dot | |
449 | (<literal>.</literal>) are not shown. To show these too, | |
450 | specify <option>--all</option>. Note that a special image | |
451 | <literal>.host</literal> always implicitly exists and refers | |
452 | to the image the host itself is booted from.</para></listitem> | |
453 | </varlistentry> | |
454 | ||
455 | <varlistentry> | |
456 | <term><command>image-status</command> <replaceable>NAME</replaceable>...</term> | |
457 | ||
458 | <listitem><para>Show terse status information about one or | |
459 | more container or VM images. This function is intended to | |
460 | generate human-readable output. Use | |
461 | <command>show-image</command> (see below) to generate | |
462 | computer-parsable output instead.</para></listitem> | |
463 | </varlistentry> | |
464 | ||
465 | <varlistentry> | |
466 | <term><command>show-image</command> <replaceable>NAME</replaceable>...</term> | |
467 | ||
468 | <listitem><para>Show properties of one or more registered | |
469 | virtual machine or container images, or the manager itself. If | |
470 | no argument is specified, properties of the manager will be | |
471 | shown. If an NAME is specified, properties of this virtual | |
472 | machine or container image are shown. By default, empty | |
473 | properties are suppressed. Use <option>--all</option> to show | |
474 | those too. To select specific properties to show, use | |
475 | <option>--property=</option>. This command is intended to be | |
476 | used whenever computer-parsable output is required. Use | |
477 | <command>image-status</command> if you are looking for | |
478 | formatted human-readable output.</para></listitem> | |
479 | </varlistentry> | |
480 | ||
481 | <varlistentry> | |
482 | <term><command>clone</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term> | |
483 | ||
e3bff60a | 484 | <listitem><para>Clones a container or VM image. The |
e735f4d4 MP |
485 | arguments specify the name of the image to clone and the name |
486 | of the newly cloned image. Note that plain directory container | |
487 | images are cloned into subvolume images with this command. | |
488 | Note that cloning a container or VM image is optimized for | |
489 | btrfs file systems, and might not be efficient on others, due | |
e3bff60a MP |
490 | to file system limitations.</para> |
491 | ||
492 | <para>Note that this command leaves host name, machine ID and | |
493 | all other settings that could identify the instance | |
494 | unmodified. The original image and the cloned copy will hence | |
495 | share these credentials, and it might be necessary to manually | |
496 | change them in the copy.</para></listitem> | |
e735f4d4 MP |
497 | </varlistentry> |
498 | ||
499 | <varlistentry> | |
500 | <term><command>rename</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term> | |
501 | ||
e3bff60a | 502 | <listitem><para>Renames a container or VM image. The |
e735f4d4 MP |
503 | arguments specify the name of the image to rename and the new |
504 | name of the image.</para></listitem> | |
505 | </varlistentry> | |
506 | ||
507 | <varlistentry> | |
508 | <term><command>read-only</command> <replaceable>NAME</replaceable> [<replaceable>BOOL</replaceable>]</term> | |
509 | ||
e3bff60a | 510 | <listitem><para>Marks or (unmarks) a container or VM image |
e735f4d4 MP |
511 | read-only. Takes a VM or container image name, followed by a |
512 | boolean as arguments. If the boolean is omitted, positive is | |
513 | implied, i.e. the image is marked read-only.</para></listitem> | |
514 | </varlistentry> | |
515 | ||
e735f4d4 MP |
516 | <varlistentry> |
517 | <term><command>remove</command> <replaceable>NAME</replaceable>...</term> | |
518 | ||
e3bff60a | 519 | <listitem><para>Removes one or more container or VM images. |
e735f4d4 MP |
520 | The special image <literal>.host</literal>, which refers to |
521 | the host's own directory tree may not be | |
522 | removed.</para></listitem> | |
523 | </varlistentry> | |
524 | ||
e3bff60a MP |
525 | <varlistentry> |
526 | <term><command>set-limit</command> [<replaceable>NAME</replaceable>] <replaceable>BYTES</replaceable></term> | |
527 | ||
528 | <listitem><para>Sets the maximum size in bytes a specific | |
529 | container or VM image, or all images may grow up to on disk | |
530 | (disk quota). Takes either one or two parameters. The first, | |
531 | optional parameter refers to a container or VM image name. If | |
532 | specified the size limit of the specified image is changed. If | |
533 | omitted the overall size limit of the sum of all images stored | |
534 | locally is changed. The final argument specifies the size | |
535 | limit in bytes, possibly suffixed by the usual K, M, G, T | |
536 | units. If the size limit shall be disabled, specify | |
537 | <literal>-</literal> as size.</para> | |
538 | ||
539 | <para>Note that per-container size limits are only supported | |
540 | on btrfs file systems. Also note that if | |
541 | <command>set-limit</command> is invoked without image | |
542 | parameter, and <filename>/var/lib/machines</filename> is | |
543 | empty, and the directory is not located on btrfs, a btrfs | |
544 | loopback file is implicitly created as | |
545 | <filename>/var/lib/machines.raw</filename> with the given | |
546 | size, and mounted to | |
547 | <filename>/var/lib/machines</filename>. The size of the | |
548 | loopback may later be readjusted with | |
549 | <command>set-limit</command>, as well. If such a | |
550 | loopback-mounted <filename>/var/lib/machines</filename> | |
551 | directory is used <command>set-limit</command> without image | |
552 | name alters both the quota setting within the file system as | |
553 | well as the loopback file and file system size | |
554 | itself.</para></listitem> | |
555 | </varlistentry> | |
556 | ||
e735f4d4 MP |
557 | </variablelist></refsect2> |
558 | ||
559 | <refsect2><title>Image Transfer Commands</title><variablelist> | |
560 | ||
561 | <varlistentry> | |
562 | <term><command>pull-tar</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term> | |
563 | ||
564 | <listitem><para>Downloads a <filename>.tar</filename> | |
565 | container image from the specified URL, and makes it available | |
566 | under the specified local machine name. The URL must be of | |
567 | type <literal>http://</literal> or | |
568 | <literal>https://</literal>, and must refer to a | |
569 | <filename>.tar</filename>, <filename>.tar.gz</filename>, | |
570 | <filename>.tar.xz</filename> or <filename>.tar.bz2</filename> | |
e3bff60a | 571 | archive file. If the local machine name is omitted it |
e735f4d4 MP |
572 | is automatically derived from the last component of the URL, |
573 | with its suffix removed.</para> | |
574 | ||
575 | <para>The image is verified before it is made available, | |
576 | unless <option>--verify=no</option> is specified. Verification | |
577 | is done via SHA256SUMS and SHA256SUMS.gpg files, that need to | |
578 | be made available on the same web server, under the same URL | |
579 | as the <filename>.tar</filename> file, but with the last | |
580 | component (the filename) of the URL replaced. With | |
581 | <option>--verify=checksum</option> only the SHA256 checksum | |
582 | for the file is verified, based on the | |
583 | <filename>SHA256SUMS</filename> file. With | |
584 | <option>--verify=signature</option> the SHA256SUMS file is | |
585 | first verified with detached GPG signature file | |
586 | <filename>SHA256SUMS.gpg</filename>. The public key for this | |
587 | verification step needs to be available in | |
588 | <filename>/usr/lib/systemd/import-pubring.gpg</filename> or | |
589 | <filename>/etc/systemd/import-pubring.gpg</filename>.</para> | |
590 | ||
591 | <para>The container image will be downloaded and stored in a | |
592 | read-only subvolume in | |
593 | <filename>/var/lib/machines/</filename>, that is named after | |
594 | the specified URL and its HTTP etag. A writable snapshot is | |
595 | then taken from this subvolume, and named after the specified | |
7035cd9e | 596 | local name. This behavior ensures that creating multiple |
e735f4d4 MP |
597 | container instances of the same URL is efficient, as multiple |
598 | downloads are not necessary. In order to create only the | |
599 | read-only image, and avoid creating its writable snapshot, | |
600 | specify <literal>-</literal> as local machine name.</para> | |
601 | ||
602 | <para>Note that the read-only subvolume is prefixed with | |
e3bff60a | 603 | <filename>.tar-</filename>, and is thus not shown by |
e735f4d4 MP |
604 | <command>list-images</command>, unless <option>--all</option> |
605 | is passed.</para> | |
606 | ||
607 | <para>Note that pressing C-c during execution of this command | |
608 | will not abort the download. Use | |
609 | <command>cancel-transfer</command>, described | |
610 | below.</para></listitem> | |
611 | </varlistentry> | |
612 | ||
613 | <varlistentry> | |
614 | <term><command>pull-raw</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term> | |
615 | ||
616 | <listitem><para>Downloads a <filename>.raw</filename> | |
617 | container or VM disk image from the specified URL, and makes | |
618 | it available under the specified local machine name. The URL | |
619 | must be of type <literal>http://</literal> or | |
620 | <literal>https://</literal>. The container image must either | |
621 | be a <filename>.qcow2</filename> or raw disk image, optionally | |
622 | compressed as <filename>.gz</filename>, | |
623 | <filename>.xz</filename>, or <filename>.bz2</filename>. If the | |
e3bff60a | 624 | local machine name is omitted it is automatically |
e735f4d4 MP |
625 | derived from the last component of the URL, with its suffix |
626 | removed.</para> | |
627 | ||
628 | <para>Image verification is identical for raw and tar images | |
629 | (see above).</para> | |
630 | ||
fb183854 | 631 | <para>If the downloaded image is in |
e3bff60a | 632 | <filename>.qcow2</filename> format it is converted into a raw |
e735f4d4 MP |
633 | image file before it is made available.</para> |
634 | ||
635 | <para>Downloaded images of this type will be placed as | |
636 | read-only <filename>.raw</filename> file in | |
637 | <filename>/var/lib/machines/</filename>. A local, writable | |
638 | (reflinked) copy is then made under the specified local | |
639 | machine name. To omit creation of the local, writable copy | |
640 | pass <literal>-</literal> as local machine name.</para> | |
641 | ||
7035cd9e | 642 | <para>Similar to the behavior of <command>pull-tar</command>, |
e735f4d4 | 643 | the read-only image is prefixed with |
e3bff60a | 644 | <filename>.raw-</filename>, and thus not shown by |
e735f4d4 MP |
645 | <command>list-images</command>, unless <option>--all</option> |
646 | is passed.</para> | |
647 | ||
648 | <para>Note that pressing C-c during execution of this command | |
649 | will not abort the download. Use | |
650 | <command>cancel-transfer</command>, described | |
651 | below.</para></listitem> | |
652 | </varlistentry> | |
653 | ||
654 | <varlistentry> | |
655 | <term><command>pull-dkr</command> <replaceable>REMOTE</replaceable> [<replaceable>NAME</replaceable>]</term> | |
656 | ||
657 | <listitem><para>Downloads a <literal>dkr</literal> container | |
658 | image and makes it available locally. The remote name refers | |
659 | to a <literal>dkr</literal> container name. If omitted, the | |
660 | local machine name is derived from the <literal>dkr</literal> | |
661 | container name.</para> | |
662 | ||
663 | <para>Image verification is not available for | |
664 | <literal>dkr</literal> containers, and thus | |
665 | <option>--verify=no</option> must always be specified with | |
666 | this command.</para> | |
667 | ||
668 | <para>This command downloads all (missing) layers for the | |
669 | specified container and places them in read-only subvolumes in | |
670 | <filename>/var/lib/machines/</filename>. A writable snapshot | |
671 | of the newest layer is then created under the specified local | |
672 | machine name. To omit creation of this writable snapshot, pass | |
673 | <literal>-</literal> as local machine name.</para> | |
674 | ||
675 | <para>The read-only layer subvolumes are prefixed with | |
e3bff60a | 676 | <filename>.dkr-</filename>, and thus not shown by |
e735f4d4 MP |
677 | <command>list-images</command>, unless <option>--all</option> |
678 | is passed.</para> | |
679 | ||
680 | <para>To specify the <literal>dkr</literal> index server to | |
681 | use for looking up the specified container, use | |
682 | <option>--dkr-index-url=</option>.</para> | |
683 | ||
684 | <para>Note that pressing C-c during execution of this command | |
685 | will not abort the download. Use | |
686 | <command>cancel-transfer</command>, described | |
687 | below.</para></listitem> | |
688 | </varlistentry> | |
689 | ||
e3bff60a MP |
690 | <varlistentry> |
691 | <term><command>import-tar</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term> | |
692 | <term><command>import-raw</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term> | |
693 | <listitem><para>Imports a TAR or RAW container or VM image, | |
694 | and places it under the specified name in | |
695 | <filename>/var/lib/machines/</filename>. When | |
696 | <command>import-tar</command> is used the file specified as | |
697 | first argument should be a tar archive, possibly compressed | |
698 | with xz, gzip or bzip2. It will then be unpacked into its own | |
699 | subvolume in <filename>/var/lib/machines</filename>. When | |
700 | <command>import-raw</command> is used the file should be a | |
701 | qcow2 or raw disk image, possibly compressed with xz, gzip or | |
702 | bzip2. If the second argument (the resulting image name) is | |
703 | not specified it is automatically derived from the file | |
704 | name. If the file name is passed as <literal>-</literal> the | |
705 | image is read from standard input, in which case the second | |
706 | argument is mandatory.</para> | |
707 | ||
708 | <para>Similar as with <command>pull-tar</command>, | |
709 | <command>pull-raw</command> the file system | |
710 | <filename>/var/lib/machines.raw</filename> is increased in | |
711 | size of necessary and appropriate. Optionally the | |
712 | <option>--read-only</option> switch may be used to create a | |
713 | read-only container or VM image. No cryptographic validation | |
714 | is done when importing the images.</para> | |
715 | ||
716 | <para>Much like image downloads, ongoing imports may be listed | |
717 | with <command>list-transfers</command> and aborted with | |
718 | <command>cancel-transfer</command>.</para></listitem> | |
719 | </varlistentry> | |
720 | ||
721 | <varlistentry> | |
722 | <term><command>export-tar</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term> | |
723 | <term><command>export-raw</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term> | |
724 | <listitem><para>Exports a TAR or RAW container or VM image and | |
725 | stores it in the specified file. The first parameter should be | |
726 | a VM or container image name. The second parameter should be a | |
727 | file path the TAR or RAW image is written to. If the path ends | |
728 | in <literal>.gz</literal> the file is compressed with gzip, if | |
729 | it ends in <literal>.xz</literal> with xz, and if it ends in | |
730 | <literal>.bz2</literal> with bzip2. If the path ends in | |
731 | neither the file is left uncompressed. If the second argument | |
732 | is missing the image is written to standard output. The | |
733 | compression may also be explicitly selected with the | |
734 | <option>--format=</option> switch. This is in particular | |
735 | useful if the second parameter is left unspecified.</para> | |
736 | ||
737 | <para>Much like image downloads and imports, ongoing exports | |
738 | may be listed with <command>list-transfers</command> and | |
739 | aborted with | |
740 | <command>cancel-transfer</command>.</para> | |
741 | ||
742 | <para>Note that currently only directory and subvolume images | |
743 | may be exported as TAR images, and only raw disk images as RAW | |
744 | images.</para></listitem> | |
745 | </varlistentry> | |
746 | ||
e735f4d4 MP |
747 | <varlistentry> |
748 | <term><command>list-transfers</command></term> | |
749 | ||
750 | <listitem><para>Shows a list of container or VM image | |
e3bff60a MP |
751 | downloads, imports and exports that are currently in |
752 | progress.</para></listitem> | |
e735f4d4 MP |
753 | </varlistentry> |
754 | ||
755 | <varlistentry> | |
756 | <term><command>cancel-transfers</command> <replaceable>ID</replaceable>...</term> | |
757 | ||
e3bff60a MP |
758 | <listitem><para>Aborts a download, import or export of the |
759 | container or VM image with the specified ID. To list ongoing | |
760 | transfers and their IDs, use | |
761 | <command>list-transfers</command>. </para></listitem> | |
e735f4d4 MP |
762 | </varlistentry> |
763 | ||
764 | </variablelist></refsect2> | |
765 | ||
766 | </refsect1> | |
767 | ||
768 | <refsect1> | |
769 | <title>Files and Directories</title> | |
770 | ||
771 | <para>Machine images are preferably stored in | |
772 | <filename>/var/lib/machines/</filename>, but are also searched for | |
773 | in <filename>/usr/local/lib/machines/</filename> and | |
774 | <filename>/usr/lib/machines/</filename>. For compatibility reasons | |
775 | the directory <filename>/var/lib/container/</filename> is | |
776 | searched, too. Note that images stored below | |
777 | <filename>/usr</filename> are always considered read-only. It is | |
778 | possible to symlink machines images from other directories into | |
779 | <filename>/var/lib/machines/</filename> to make them available for | |
780 | control with <command>machinectl</command>.</para> | |
781 | ||
e3bff60a MP |
782 | <para>Note that many image operations are only supported, |
783 | efficient or atomic on btrfs file systems. Due to this, if the | |
784 | <command>pull-tar</command>, <command>pull-raw</command>, | |
785 | <command>pull-dkr</command>, <command>import-tar</command>, | |
786 | <command>import-raw</command> and <command>set-limit</command> | |
787 | commands notice that <filename>/var/lib/machines</filename> is | |
788 | empty and not located on btrfs, they will implicitly set up a | |
789 | loopback file <filename>/var/lib/machines.raw</filename> | |
790 | containing a btrfs file system that is mounted to | |
791 | <filename>/var/lib/machines</filename>. The size of this loopback | |
792 | file may be controlled dynamically with | |
793 | <command>set-limit</command>.</para> | |
794 | ||
e735f4d4 MP |
795 | <para>Disk images are understood by |
796 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
797 | and <command>machinectl</command> in three formats:</para> | |
798 | ||
799 | <itemizedlist> | |
800 | <listitem><para>A simple directory tree, containing the files | |
801 | and directories of the container to boot.</para></listitem> | |
802 | ||
803 | <listitem><para>A subvolume (on btrfs file systems), which are | |
804 | similar to the simple directories, described above. However, | |
805 | they have additional benefits, such as efficient cloning and | |
806 | quota reporting.</para></listitem> | |
807 | ||
808 | <listitem><para>"Raw" disk images, i.e. binary images of disks | |
809 | with a GPT or MBR partition table. Images of this type are | |
810 | regular files with the suffix | |
811 | <literal>.raw</literal>.</para></listitem> | |
812 | </itemizedlist> | |
813 | ||
814 | <para>See | |
815 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
816 | for more information on image formats, in particular it's | |
817 | <option>--directory=</option> and <option>--image=</option> | |
818 | options.</para> | |
819 | </refsect1> | |
820 | ||
821 | <refsect1> | |
822 | <title>Examples</title> | |
823 | <example> | |
824 | <title>Download an Ubuntu image and open a shell in it</title> | |
825 | ||
826 | <programlisting># machinectl pull-tar https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.gz | |
827 | # systemd-nspawn -M trusty-server-cloudimg-amd64-root</programlisting> | |
828 | ||
829 | <para>This downloads and verifies the specified | |
830 | <filename>.tar</filename> image, and then uses | |
831 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
832 | to open a shell in it.</para> | |
833 | </example> | |
834 | ||
835 | <example> | |
836 | <title>Download a Fedora image, set a root password in it, start | |
837 | it as service</title> | |
838 | ||
e3bff60a MP |
839 | <programlisting># machinectl pull-raw --verify=no http://ftp.halifax.rwth-aachen.de/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora-Cloud-Base-20141203-21.x86_64.raw.xz |
840 | # systemd-nspawn -M Fedora-Cloud-Base-20141203-21 | |
841 | # passwd | |
842 | # exit | |
843 | # machinectl start Fedora-Cloud-Base-20141203-21 | |
844 | # machinectl login Fedora-Cloud-Base-20141203-21</programlisting> | |
e735f4d4 MP |
845 | |
846 | <para>This downloads the specified <filename>.raw</filename> | |
847 | image with verification disabled. Then a shell is opened in it | |
848 | and a root password is set. Afterwards the shell is left, and | |
849 | the machine started as system service. With the last command a | |
850 | login prompt into the container is requested.</para> | |
851 | </example> | |
852 | ||
853 | <example> | |
854 | <title>Download a Fedora <literal>dkr</literal> image</title> | |
855 | ||
856 | <programlisting># machinectl pull-dkr --verify=no mattdm/fedora | |
857 | # systemd-nspawn -M fedora</programlisting> | |
858 | ||
859 | <para>Downloads a <literal>dkr</literal> image and opens a shell | |
860 | in it. Note that the specified download command might require an | |
861 | index server to be specified with the | |
862 | <literal>--dkr-index-url=</literal>.</para> | |
863 | </example> | |
e3bff60a MP |
864 | |
865 | <example> | |
866 | <title>Exports a container image as tar file</title> | |
867 | ||
868 | <programlisting># machinectl export-tar fedora myfedora.tar.xz</programlisting> | |
869 | ||
870 | <para>Exports the container <literal>fedora</literal> in an | |
871 | xz-compress tar file <filename>myfedora.tar.xz</filename> in the | |
872 | current directory.</para> | |
873 | </example> | |
874 | ||
e735f4d4 MP |
875 | </refsect1> |
876 | ||
877 | <refsect1> | |
878 | <title>Exit status</title> | |
879 | ||
880 | <para>On success, 0 is returned, a non-zero failure code | |
881 | otherwise.</para> | |
882 | </refsect1> | |
883 | ||
884 | <xi:include href="less-variables.xml" /> | |
885 | ||
886 | <refsect1> | |
887 | <title>See Also</title> | |
888 | <para> | |
889 | <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
890 | <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
e3bff60a MP |
891 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
892 | <citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
893 | <citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
894 | <citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
895 | <citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
e735f4d4 MP |
896 | </para> |
897 | </refsect1> | |
14228c0d MB |
898 | |
899 | </refentry> |