Debian Codegraph @

man/importctl.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM "custom-entities.ent" >
5 %entities;
6 ]>
7 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
8
9 <refentry id="importctl" conditional='ENABLE_MACHINED'
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>importctl</title>
14 <productname>systemd</productname>
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>importctl</refentrytitle>
19 <manvolnum>1</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>importctl</refname>
24 <refpurpose>Download, import or export disk images</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <cmdsynopsis>
29 <command>importctl</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>importctl</command> may be used to download, import, and export disk images via
40 <citerefentry><refentrytitle>systemd-importd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
41
42 <para><command>importctl</command> operates both on block-level disk images (such as DDIs),
43 file-system-level images (tarballs), as well as OCI images. It supports disk images in one of the four
44 following classes:</para>
45
46 <itemizedlist>
47 <listitem><para>VM images or full OS container images, that may be run via
48 <citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> or
49 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>, and
50 managed via
51 <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para></listitem>
52
53 <listitem><para>Portable service images, that may be attached and managed via
54 <citerefentry><refentrytitle>portablectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para></listitem>
55
56 <listitem><para>System extension (sysext) images, that may be activated via
57 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para></listitem>
58
59 <listitem><para>Configuration extension (confext) images, that may be activated via
60 <citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para></listitem>
61 </itemizedlist>
62
63 <para>When images are downloaded or imported they are placed in the following directories, depending on
64 the <option>--class=</option> parameter:</para>
65
66 <table>
67 <title>Classes and Directories</title>
68 <tgroup cols='2'>
69 <colspec colname='class' />
70 <colspec colname='directory' />
71 <thead>
72 <row>
73 <entry>Class</entry>
74 <entry>Directory</entry>
75 </row>
76 </thead>
77 <tbody>
78 <row>
79 <entry><literal>machine</literal></entry>
80 <entry><filename>/var/lib/machines/</filename></entry>
81 </row>
82 <row>
83 <entry><literal>portable</literal></entry>
84 <entry><filename>/var/lib/portables/</filename></entry>
85 </row>
86 <row>
87 <entry><literal>sysext</literal></entry>
88 <entry><filename>/var/lib/extensions/</filename></entry>
89 </row>
90 <row>
91 <entry><literal>confext</literal></entry>
92 <entry><filename>/var/lib/confexts/</filename></entry>
93 </row>
94 </tbody>
95 </tgroup>
96 </table>
97 </refsect1>
98
99 <refsect1>
100 <title>Commands</title>
101
102 <para>The following commands are understood:</para>
103
104 <variablelist>
105 <varlistentry>
106 <term><command>pull-tar</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
107
108 <listitem><para>Downloads a <filename>.tar</filename> image from the specified URL, and makes it
109 available under the specified local name in the image directory for the selected
110 <option>--class=</option>. The URL must be of type <literal>http://</literal> or
111 <literal>https://</literal>, and must refer to a <filename>.tar</filename>,
112 <filename>.tar.gz</filename>, <filename>.tar.xz</filename> or <filename>.tar.bz2</filename> archive
113 file. If the local image name is omitted, it is automatically derived from the last component of the
114 URL, with its suffix removed.</para>
115
116 <para>The image is verified before it is made available, unless <option>--verify=no</option> is
117 specified. Verification is done either via a file with the name of the image and the
118 suffix <filename>.sha256</filename> and a detached <filename>.sha256.asc</filename> or
119 <filename>.sha256.gpg</filename> signature or via separate <filename>SHA256SUMS</filename> and
120 <filename>SHA256SUMS.asc</filename> or <filename>SHA256SUMS.gpg</filename> files. The signature
121 files need to be made available on the same web server, under the same URL as the
122 <filename>.tar</filename> file. With
123 <option>--verify=checksum</option>, only the SHA256 checksum for the file is verified, based on the
124 <filename>.sha256</filename> suffixed file or the <filename>SHA256SUMS</filename> file. With
125 <option>--verify=signature</option>, the sha checksum file is first verified with the detached GPG
126 signature of <filename>.sha256</filename> or <filename>SHA256SUMS</filename>. The public key for
127 this verification step needs to be available in
128 <filename>/usr/lib/systemd/import-pubring.pgp</filename> or
129 <filename>/etc/systemd/import-pubring.pgp</filename>.</para>
130
131 <para>If <option>-keep-download=yes</option> is specified the image will be downloaded and stored in
132 a read-only subvolume/directory in the image directory that is named after the specified URL and its
133 HTTP etag (see <ulink url="https://en.wikipedia.org/wiki/HTTP_ETag">HTTP ETag</ulink> for more
134 information). A writable snapshot is then taken from this subvolume, and named after the specified local
135 name. This behavior ensures that creating multiple instances of the same URL is efficient, as
136 multiple downloads are not necessary. In order to create only the read-only image, and avoid creating
137 its writable snapshot, specify <literal>-</literal> as local name.</para>
138
139 <para>Note that pressing Control-c during execution of this command will not abort the download. Use
140 <command>cancel-transfer</command>, described below.</para>
141
142 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
143 </varlistentry>
144
145 <varlistentry>
146 <term><command>pull-raw</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
147
148 <listitem><para>Downloads a <filename>.raw</filename> disk image from the specified URL, and makes it
149 available under the specified local name in the image directory for the selected
150 <option>--class=</option>. The URL must be of type <literal>http://</literal> or
151 <literal>https://</literal>. The image must either be a qcow2 or raw disk
152 image, optionally compressed as <filename>.gz</filename>, <filename>.xz</filename>, or
153 <filename>.bz2</filename>. If the local name is omitted, it is automatically derived from the last
154 component of the URL, with its suffix removed.</para>
155
156 <para>Image verification is identical for raw and tar images (see above).</para>
157
158 <para>If the downloaded image is in qcow2 format it is converted into a raw
159 image file before it is made available.</para>
160
161 <para>If <option>-keep-download=yes</option> is specified the image will be downloaded and stored in
162 a read-only file in the image directory that is named after the specified URL and its HTTP etag. A
163 writable copy is then made from this file, and named after the specified local name. This behavior
164 ensures that creating multiple instances of the same URL is efficient, as multiple downloads are not
165 necessary. In order to create only the read-only image, and avoid creating its writable copy,
166 specify <literal>-</literal> as local name.</para>
167
168 <para>Note that pressing Control-c during execution of this command will not abort the download. Use
169 <command>cancel-transfer</command>, described below.</para>
170
171 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
172 </varlistentry>
173
174 <varlistentry>
175 <term><command>pull-oci</command> <replaceable>REF</replaceable> [<replaceable>NAME</replaceable>]</term>
176
177 <listitem><para>Downloads the specified OCI container image, and makes it available under the
178 specified local name in the image directory for the selected <option>--class=</option>. The first
179 argument must be an OCI container reference, such as <literal>library/nginx</literal> If the local
180 name is omitted, it is automatically derived from the last component of the URL, with its suffix
181 removed.</para>
182
183 <para>When downloading images of this type no image verification is done beyond the usual
184 authentication of the HTTPS certificates.</para>
185
186 <para>Note that pressing Control-c during execution of this command will not abort the download. Use
187 <command>cancel-transfer</command>, described below.</para>
188
189 <xi:include href="version-info.xml" xpointer="v260"/></listitem>
190 </varlistentry>
191
192 <varlistentry>
193 <term><command>import-tar</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
194 <term><command>import-raw</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
195
196 <listitem><para>Imports a TAR or RAW image, and places it under the specified name in the image
197 directory for the image class selected via <option>--class=</option>. When
198 <command>import-tar</command> is used, the file specified as the first argument should be a
199 <citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry>
200 archive, possibly compressed with
201 <citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
202 <citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
203 <citerefentry project='die-net'><refentrytitle>zstd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
204 or
205 <citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
206 It will then be unpacked into its own
207 subvolume/directory. When <command>import-raw</command> is used, the file should be a qcow2 or raw
208 disk image, possibly compressed with xz, gzip, zstd or bzip2. If the second argument (the resulting image
209 name) is not specified, it is automatically derived from the file name. If the filename is passed as
210 <literal>-</literal>, the image is read from standard input, in which case the second argument is
211 mandatory.</para>
212
213 <para>No cryptographic validation is done when importing the images.</para>
214
215 <para>Much like image downloads, ongoing imports may be listed with <command>list</command>
216 and aborted with <command>cancel-transfer</command>.</para>
217
218 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
219 </varlistentry>
220
221 <varlistentry>
222 <term><command>import-fs</command> <replaceable>DIRECTORY</replaceable> [<replaceable>NAME</replaceable>]</term>
223
224 <listitem><para>Imports an image stored in a local directory into the image directory for the image
225 class selected via <option>--class=</option> and operates similarly to <command>import-tar</command>
226 or <command>import-raw</command>, but the first argument is the source directory. If supported, this
227 command will create a
228 <citerefentry project="url"><refentrytitle url="https://btrfs.readthedocs.io/en/latest/btrfs.html">btrfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
229 snapshot or subvolume for the new image.</para>
230
231 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
232 </varlistentry>
233
234 <varlistentry>
235 <term><command>export-tar</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
236 <term><command>export-raw</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
237
238 <listitem><para>Exports a TAR or RAW image and stores it in the specified file. The first parameter
239 should be an image name. The second parameter should be a file path the TAR or RAW
240 image is written to. If the path ends in <literal>.gz</literal>, the file is compressed with
241 <citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
242 if it ends in <literal>.xz</literal>, with
243 <citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
244 if it ends in <literal>.zst</literal>, with
245 <citerefentry project='die-net'><refentrytitle>zstd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
246 and if it ends in <literal>.bz2</literal>, with
247 <citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
248 If the path ends in neither, the file is left uncompressed. If the second argument is missing, the image
249 is written to standard output. The compression may also be explicitly selected with the
250 <option>--format=</option> switch. This is in particular useful if the second parameter is left
251 unspecified.</para>
252
253 <para>Much like image downloads and imports, ongoing exports may be listed with
254 <command>list</command> and aborted with <command>cancel-transfer</command>.</para>
255
256 <para>Note that, currently, only directory and subvolume images may be exported as TAR images, and
257 only raw disk images as RAW images.</para>
258
259 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
260 </varlistentry>
261
262 <varlistentry>
263 <term><command>list-transfer</command></term>
264
265 <listitem><para>Shows a list of image downloads, imports and exports that are currently in
266 progress.</para>
267
268 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
269 </varlistentry>
270
271 <varlistentry>
272 <term><command>cancel-transfer</command> <replaceable>ID</replaceable>…</term>
273
274 <listitem><para>Aborts a download, import or export of the image with the specified ID. To list
275 ongoing transfers and their IDs, use <command>list</command>. </para>
276
277 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
278 </varlistentry>
279
280 <varlistentry>
281 <term><command>list-images</command></term>
282
283 <listitem><para>Shows a list of already downloaded/imported images.</para>
284
285 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
286 </varlistentry>
287
288 </variablelist>
289 </refsect1>
290
291 <refsect1>
292 <title>Options</title>
293
294 <para>The following options are understood:</para>
295
296 <variablelist>
297 <varlistentry>
298 <term><option>--read-only</option></term>
299
300 <listitem>
301 <para>When used with <command>pull-raw</command>, <command>pull-tar</command>,
302 <command>import-raw</command>, <command>import-tar</command> or <command>import-fs</command> a
303 read-only image is created.</para>
304
305 <xi:include href="version-info.xml" xpointer="v256"/>
306 </listitem>
307 </varlistentry>
308
309 <varlistentry>
310 <term><option>--verify=</option></term>
311
312 <listitem><para>When downloading an image, specify whether the image shall be verified before it is
313 made available. Takes one of <literal>no</literal>, <literal>checksum</literal> and
314 <literal>signature</literal>. If <literal>no</literal>, no verification is done. If
315 <literal>checksum</literal> is specified, the download is checked for integrity after the transfer is
316 complete, but no signatures are verified. If <literal>signature</literal> is specified, the checksum
317 is verified and the image's signature is checked against a local keyring of trustable vendors. It is
318 strongly recommended to set this option to <literal>signature</literal> if the server and protocol
319 support this. Defaults to <literal>signature</literal>.</para>
320
321 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
322 </varlistentry>
323
324 <varlistentry>
325 <term><option>--force</option></term>
326
327 <listitem><para>When downloading an image, and a local copy by the specified local name already
328 exists, delete it first and replace it by the newly downloaded image.</para>
329
330 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
331 </varlistentry>
332
333 <varlistentry>
334 <term><option>--format=</option></term>
335
336 <listitem><para>When used with the <option>export-tar</option> or <option>export-raw</option>
337 commands, specifies the compression format to use for the resulting file. Takes one of
338 <literal>uncompressed</literal>, <literal>xz</literal>, <literal>gzip</literal>,
339 <literal>zst</literal>, <literal>bzip2</literal>. By default, the format is determined
340 automatically from the output image file name passed.</para>
341
342 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
343 </varlistentry>
344
345 <varlistentry>
346 <term><option>-q</option></term>
347 <term><option>--quiet</option></term>
348
349 <listitem><para>Suppresses additional informational output while running.</para>
350
351 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
352 </varlistentry>
353
354 <xi:include href="user-system-options.xml" xpointer="host" />
355
356 <varlistentry>
357 <term><option>-M</option></term>
358 <term><option>--machine=</option></term>
359
360 <listitem><para>Connect to
361 <citerefentry><refentrytitle>systemd-importd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
362 running in a local container, to perform the specified operation within the container.</para>
363
364 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
365 </varlistentry>
366
367 <varlistentry>
368 <term><option>--class=</option></term>
369 <term><option>-m</option></term>
370 <term><option>-P</option></term>
371 <term><option>-S</option></term>
372 <term><option>-C</option></term>
373
374 <listitem><para>Selects the image class for the downloaded images. This primarily selects the
375 directory to download into. The <option>--class=</option> switch takes <literal>machine</literal>,
376 <literal>portable</literal>, <literal>sysext</literal> or <literal>confext</literal> as argument. The
377 short options <option>-m</option>, <option>-P</option>, <option>-S</option>, <option>-C</option> are
378 shortcuts for <option>--class=machine</option>, <option>--class=portable</option>,
379 <option>--class=sysext</option>, <option>--class=confext</option>.</para>
380
381 <para>Note that <option>--keep-download=</option> defaults to true for
382 <option>--class=machine</option> and false otherwise, see below.</para>
383
384 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
385 </varlistentry>
386
387 <varlistentry>
388 <term><option>--keep-download=</option></term>
389 <term><option>-N</option></term>
390
391 <listitem><para>Takes a boolean argument. When specified with <command>pull-raw</command> or
392 <command>pull-tar</command>, selects whether to download directly into the specified local image
393 name, or whether to download into a read-only copy first of which to make a writable copy after the
394 download is completed. Defaults to true for <option>--class=machine</option>, false otherwise.</para>
395
396 <para>The <option>-N</option> switch is a shortcut for <option>--keep-download=no</option>.</para>
397 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
398 </varlistentry>
399
400 <xi:include href="standard-options.xml" xpointer="json" />
401 <xi:include href="standard-options.xml" xpointer="j" />
402 <xi:include href="standard-options.xml" xpointer="no-pager" />
403 <xi:include href="standard-options.xml" xpointer="no-legend" />
404 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
405 <xi:include href="standard-options.xml" xpointer="help" />
406 <xi:include href="standard-options.xml" xpointer="version" />
407 </variablelist>
408 </refsect1>
409
410 <refsect1>
411 <title>Examples</title>
412 <example id="example-import-tar">
413 <title>Download an Ubuntu TAR image and open a shell in it</title>
414
415 <programlisting># importctl pull-tar -mN https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-root.tar.xz
416 # systemd-nspawn -M jammy-server-cloudimg-amd64-root</programlisting>
417
418 <para>This downloads and verifies the specified <filename>.tar</filename> image, and then uses
419 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> to
420 open a shell in it.</para>
421 </example>
422
423 <example id="example-import-raw">
424 <title>Download an Ubuntu RAW image, set a root password in it, start
425 it as a service</title>
426
427 <programlisting># importctl pull-raw -mN \
428 https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img \
429 jammy
430 # systemd-firstboot --image=/var/lib/machines/jammy.raw --prompt-root-password --force
431 # machinectl start jammy
432 # machinectl login jammy</programlisting>
433
434 <para>This downloads the specified <filename>.raw</filename> image and makes it available under the
435 local name <literal>jammy</literal>. Then, a root password is set with
436 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>. Afterwards
437 the machine is started as system service. With the last command a login prompt into the container is
438 requested.</para>
439 </example>
440
441 <example id="example-export-tar">
442 <title>Exports a container image as tar file</title>
443
444 <programlisting># importctl export-tar -m fedora myfedora.tar.xz</programlisting>
445
446 <para>Exports the container <literal>fedora</literal> as an xz-compressed tar file
447 <filename>myfedora.tar.xz</filename> into the current directory.</para>
448 </example>
449 </refsect1>
450
451 <refsect1>
452 <title>Exit status</title>
453
454 <para>On success, 0 is returned, a non-zero failure code
455 otherwise.</para>
456 </refsect1>
457
458 <xi:include href="common-variables.xml" />
459
460 <refsect1>
461 <title>See Also</title>
462 <para><simplelist type="inline">
463 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
464 <member><citerefentry><refentrytitle>systemd-importd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
465 <member><citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
466 <member><citerefentry><refentrytitle>systemd-vmspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
467 <member><citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
468 <member><citerefentry><refentrytitle>portablectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
469 <member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
470 <member><citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
471 <member><citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
472 <member><citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
473 <member><citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
474 <member><citerefentry project='die-net'><refentrytitle>zstd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
475 <member><citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
476 </simplelist></para>
477 </refsect1>
478
479 </refentry>