table of contents
- testing 257.7-1
- unstable 257.7-1
- experimental 258~rc2-1
IMPORTCTL(1) | importctl | IMPORTCTL(1) |
NAME¶
importctl - Download, import or export disk images
SYNOPSIS¶
importctl [OPTIONS...] {COMMAND} [NAME...]
DESCRIPTION¶
importctl may be used to download, import, and export disk images via systemd-importd.service(8).
importctl operates both on block-level disk images (such as DDIs) as well as file-system-level images (tarballs). It supports disk images in one of the four following classes:
When images are downloaded or imported they are placed in the following directories, depending on the --class= parameter:
Table 1. Classes and Directories
Class | Directory |
"machine" | /var/lib/machines/ |
"portable" | /var/lib/portables/ |
"sysext" | /var/lib/extensions/ |
"confext" | /var/lib/confexts/ |
COMMANDS¶
The following commands are understood:
pull-tar URL [NAME]
The image is verified before it is made available, unless --verify=no is specified. Verification is done either via a file with the name of the image and the suffix .sha256 and a detached .sha256.asc or .sha256.gpg signature or via separate SHA256SUMS and SHA256SUMS.asc or SHA256SUMS.gpg files. The signature files need to be made available on the same web server, under the same URL as the .tar file. With --verify=checksum, only the SHA256 checksum for the file is verified, based on the .sha256 suffixed file or the SHA256SUMS file. With --verify=signature, the sha checksum file is first verified with the detached GPG signature of .sha256 or SHA256SUMS. The public key for this verification step needs to be available in /usr/lib/systemd/import-pubring.pgp or /etc/systemd/import-pubring.pgp.
If -keep-download=yes is specified the image will be downloaded and stored in a read-only subvolume/directory in the image directory that is named after the specified URL and its HTTP etag (see HTTP ETag[1] for more information). A writable snapshot is then taken from this subvolume, and named after the specified local name. This behavior ensures that creating multiple instances of the same URL is efficient, as multiple downloads are not necessary. In order to create only the read-only image, and avoid creating its writable snapshot, specify "-" as local name.
Note that pressing Control-c during execution of this command will not abort the download. Use cancel-transfer, described below.
Added in version 256.
pull-raw URL [NAME]
Image verification is identical for raw and tar images (see above).
If the downloaded image is in qcow2 format it is converted into a raw image file before it is made available.
If -keep-download=yes is specified the image will be downloaded and stored in a read-only file in the image directory that is named after the specified URL and its HTTP etag. A writable copy is then made from this file, and named after the specified local name. This behavior ensures that creating multiple instances of the same URL is efficient, as multiple downloads are not necessary. In order to create only the read-only image, and avoid creating its writable copy, specify "-" as local name.
Note that pressing Control-c during execution of this command will not abort the download. Use cancel-transfer, described below.
Added in version 256.
import-tar FILE [NAME], import-raw FILE [NAME]
No cryptographic validation is done when importing the images.
Much like image downloads, ongoing imports may be listed with list and aborted with cancel-transfer.
Added in version 256.
import-fs DIRECTORY [NAME]
Added in version 256.
export-tar NAME [FILE], export-raw NAME [FILE]
Much like image downloads and imports, ongoing exports may be listed with list and aborted with cancel-transfer.
Note that, currently, only directory and subvolume images may be exported as TAR images, and only raw disk images as RAW images.
Added in version 256.
list-transfer
Added in version 256.
cancel-transfer ID...
Added in version 256.
list-images
Added in version 256.
OPTIONS¶
The following options are understood:
--read-only
Added in version 256.
--verify=
Added in version 256.
--force
Added in version 256.
--format=
Added in version 256.
-q, --quiet
Added in version 256.
-H, --host=
-M, --machine=
Added in version 256.
--class=, -m, -P, -S, -C
Note that --keep-download= defaults to true for --class=machine and false otherwise, see below.
Added in version 256.
--keep-download=, -N
The -N switch is a shortcut for --keep-download=no.
Added in version 256.
--json=MODE
-j
--no-pager
--no-legend
--no-ask-password
-h, --help
--version
EXAMPLES¶
Example 1. Download an Ubuntu TAR image and open a shell in it
# importctl pull-tar -mN https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-root.tar.xz # systemd-nspawn -M jammy-server-cloudimg-amd64-root
This downloads and verifies the specified .tar image, and then uses systemd-nspawn(1) to open a shell in it.
Example 2. Download an Ubuntu RAW image, set a root password in it, start it as a service
# importctl pull-raw -mN \
https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img \
jammy # systemd-firstboot --image=/var/lib/machines/jammy.raw --prompt-root-password --force # machinectl start jammy # machinectl login jammy
This downloads the specified .raw image and makes it available under the local name "jammy". Then, a root password is set with systemd-firstboot(1). Afterwards the machine is started as system service. With the last command a login prompt into the container is requested.
Example 3. Exports a container image as tar file
# importctl export-tar -m fedora myfedora.tar.xz
Exports the container "fedora" as an xz-compressed tar file myfedora.tar.xz into the current directory.
EXIT STATUS¶
On success, 0 is returned, a non-zero failure code otherwise.
ENVIRONMENT¶
$SYSTEMD_LOG_LEVEL
$SYSTEMD_LOG_COLOR
This setting is only useful when messages are written directly to the terminal, because journalctl(1) and other tools that display logs will color messages based on the log level on their own.
$SYSTEMD_LOG_TIME
This setting is only useful when messages are written directly to the terminal or a file, because journalctl(1) and other tools that display logs will attach timestamps based on the entry metadata on their own.
$SYSTEMD_LOG_LOCATION
Note that the log location is often attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TID
Note that the this information is attached as metadata to journal entries anyway. Including it directly in the message text can nevertheless be convenient when debugging programs.
$SYSTEMD_LOG_TARGET
$SYSTEMD_LOG_RATELIMIT_KMSG
$SYSTEMD_PAGER, $PAGER
Note: if $SYSTEMD_PAGERSECURE is not set, $SYSTEMD_PAGER and $PAGER can only be used to disable the pager (with "cat" or ""), and are otherwise ignored.
$SYSTEMD_LESS
Users might want to change two options in particular:
K
If the value of $SYSTEMD_LESS does not include "K", and the pager that is invoked is less, Ctrl+C will be ignored by the executable, and needs to be handled by the pager.
X
Note that setting the regular $LESS environment variable has no effect for less invocations by systemd tools.
See less(1) for more discussion.
$SYSTEMD_LESSCHARSET
Note that setting the regular $LESSCHARSET environment variable has no effect for less invocations by systemd tools.
$SYSTEMD_PAGERSECURE
This option takes a boolean argument. When set to true, the "secure mode" of the pager is enabled. In "secure mode", LESSSECURE=1 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses. Currently only less(1) is known to understand this variable and implement "secure mode".
When set to false, no limitation is placed on the pager. Setting SYSTEMD_PAGERSECURE=0 or not removing it from the inherited environment may allow the user to invoke arbitrary commands.
When $SYSTEMD_PAGERSECURE is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it. "Secure mode" is enabled if the effective UID is not the same as the owner of the login session, see geteuid(2) and sd_pid_get_owner_uid(3), or when running under sudo(8) or similar tools ($SUDO_UID is set [2]). In those cases, SYSTEMD_PAGERSECURE=1 will be set and pagers which are not known to implement "secure mode" will not be used at all. Note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience. It is recommended to explicitly set $SYSTEMD_PAGERSECURE or disable the pager.
Note that if the $SYSTEMD_PAGER or $PAGER variables are to be honoured, other than to disable the pager, $SYSTEMD_PAGERSECURE must be set too.
$SYSTEMD_COLORS
$SYSTEMD_URLIFY
SEE ALSO¶
systemd(1), systemd-importd.service(8), systemd-nspawn(1), systemd-vmspawn(1), machinectl(1), portablectl(1), systemd-sysext(8), systemd-confext(8), tar(1), xz(1), gzip(1), zstd(1), bzip2(1)
NOTES¶
- 1.
- HTTP ETag
- 2.
- It is recommended for other tools to set and check $SUDO_UID as appropriate, treating it is a common interface.
systemd 258~rc2 |