mirror of
https://github.com/xcat2/confluent.git
synced 2026-11-24 11:22:24 +00:00
286 lines
11 KiB
Markdown
286 lines
11 KiB
Markdown
# imgutil(1) -- Work with confluent OS cloning and diskless images
|
|
|
|
## SYNOPSIS
|
|
|
|
`imgutil` `build` [<options>] <scratchdir>
|
|
`imgutil` `build` `--containerfile` [<options>] <file>
|
|
`imgutil` `exec` [<options>] <scratchdir> [<cmd>...]
|
|
`imgutil` `unpack` <profilename> <scratchdir>
|
|
`imgutil` `pack` [<options>] <scratchdir> <profilename>
|
|
`imgutil` `capture` <node> <profilename>
|
|
|
|
## DESCRIPTION
|
|
|
|
**imgutil** is a utility for creating, managing, and deploying OS images for diskless boot and system cloning in a Confluent environment. It supports building images from scratch, capturing images from running systems, and packing/unpacking diskless profiles.
|
|
|
|
## COMMANDS
|
|
|
|
* `build`:
|
|
Build a new diskless image from scratch in the specified scratch directory.
|
|
With a container image as `-s` source, the image is extracted to the
|
|
scratch directory instead, and completed with the confluent initramfs
|
|
configuration, the package list and a regenerated initramfs. This
|
|
builds images made elsewhere, for example in CI. With
|
|
`--containerfile`, a Containerfile to start such an image from is
|
|
written instead.
|
|
|
|
* `exec`:
|
|
Start the specified scratch directory as a container and optionally run a command inside it.
|
|
While it runs, `/proc`, `/sys`, `/dev`, an empty `/run` and the build
|
|
system's `/etc/resolv.conf` are mounted, without changing the scratch
|
|
directory. A plain `chroot` lacks them (no DNS, no `/dev/null`), so run
|
|
chroot based tools through `imgutil exec`, see EXAMPLES. `uname` and
|
|
`/proc` report the newest kernel of the image, so DKMS builds for it,
|
|
see `-k`.
|
|
|
|
* `unpack`:
|
|
Unpack a diskless image profile to a scratch directory for modification.
|
|
|
|
* `pack`:
|
|
Pack a scratch directory into a diskless profile that can be deployed.
|
|
If the image enables SELinux in `/etc/selinux/config`, the scratch
|
|
directory is first labeled with the policy of the image. If labeling
|
|
fails, pack fails.
|
|
|
|
* `capture`:
|
|
Capture an image for cloning from a running system.
|
|
|
|
## BUILD OPTIONS
|
|
|
|
* `-r`, `--addrepos` <repository>:
|
|
Repositories to add in addition to the main source. May be specified multiple times.
|
|
|
|
* `-p`, `--packagelist` <file>:
|
|
Filename of package list to replace default pkglist.
|
|
|
|
* `-a`, `--addpackagelist` <file>:
|
|
A list of additional packages to include. May be specified multiple times.
|
|
|
|
* `-s`, `--source` <directory>|<image>:
|
|
Directory to pull installation from, typically a subdirectory of `/var/lib/confluent/distributions`. By default, the repositories for the build system are used. For Ubuntu, a distribution directory is not supported, the build system repositories are always used.
|
|
|
|
A container image made elsewhere, for example in CI, can be the source
|
|
instead: a SIF file as built by Apptainer or SingularityCE, an OCI or
|
|
Docker archive file as written by `podman save`, an OCI layout
|
|
directory with its `oci-layout` file, or a podman reference with its
|
|
transport, for example `docker://registry.example.com/hpc/compute:latest`
|
|
or `containers-storage:localhost/compute` for a local image. Local
|
|
images are looked up in the podman storage of the user running
|
|
imgutil, normally root. Any other image is pulled or loaded into a
|
|
temporary storage next to the scratch directory, which is removed
|
|
afterwards, so the images and tags of the system stay as they are. A
|
|
path containing a colon cannot be read by podman. A SIF file is
|
|
extracted from its squashfs partition, which needs
|
|
squashfs-tools 4.4 or newer but not podman.
|
|
|
|
Any other directory or name is a distribution as above. The scratch
|
|
directory must be empty or not exist. Missing packages are installed
|
|
from the repositories of the image, so an image that already has every
|
|
package builds without network access. A package list entry with a
|
|
version, such as `curl=8.5.0-2ubuntu10`, always runs the package
|
|
manager and needs the repositories. Units that container images mask
|
|
are unmasked and `/usr/sbin/policy-rc.d` is removed, so the image boots
|
|
like an installed system. Package manager settings of the image are
|
|
kept, for example container base images leaving out documentation. The
|
|
architecture is detected from the image. With `--arch`, the matching
|
|
variant of an image for several architectures is used. `-r` is not supported, as the
|
|
image brings its own repositories. EL9, Ubuntu 24.04 and SUSE 16 or
|
|
later images are supported. With `--selinux`, the full SELinux context
|
|
of every file, including the SELinux user, is set from the policy of
|
|
the image.
|
|
|
|
* `--arch` <architecture>:
|
|
Target architecture to build for (`x86_64` or `aarch64`). For Ubuntu, the
|
|
Debian-style names `amd64` and `arm64` are accepted as aliases. Building
|
|
for a foreign architecture is supported on EL and Ubuntu build hosts and
|
|
requires a statically linked qemu-user emulator registered in binfmt_misc
|
|
with the F (fix-binary) flag; on Ubuntu this is provided by the
|
|
qemu-user-static package (qemu-user-binfmt as of Ubuntu 26.04). For EL,
|
|
the architecture is also detected automatically when building from a `-s`
|
|
source tree. An aarch64 image is emulated as a Neoverse N1 cpu, which needs
|
|
qemu 7.1 or later and is much faster to emulate than the default cpu of
|
|
qemu. To emulate another cpu, set `QEMU_CPU`, for example
|
|
`QEMU_CPU=cortex-a72` for older qemu. The same applies to `imgutil exec`.
|
|
|
|
* `-y`, `--non-interactive`:
|
|
Avoid prompting for confirmation.
|
|
|
|
* `--selinux`:
|
|
Install the targeted SELinux policy and leave SELinux enforcing in the
|
|
image instead of disabling it. EL8 and newer only. Labels come from the policy
|
|
of the image. If labeling fails, for example because the build host
|
|
enforces an older policy, the build fails.
|
|
|
|
* `-v`, `--volume` <mount>:
|
|
Directory to make available in the build environment. `-v /` will cause it to be mounted in image as `/run/external/`. `-v /:/run/root` will override the target to be `/run/root`. Something like `/var/lib/repository:-` will cause it to mount to the identical path inside the image. May be specified multiple times.
|
|
|
|
* `--containerfile`:
|
|
Write a Containerfile instead of building. It installs every package
|
|
`build` checks for, generated from the same package lists, so building
|
|
from the image needs no network access. Add site specific content and
|
|
build it in CI. The OS is that of the `-s` distribution or of the build
|
|
system, as for a build, and `--arch` names the platform, so the image
|
|
can be built on another architecture with emulation. `-p`, `-a` and
|
|
`--selinux` change the packages. Pass the same options to `build`
|
|
later, as the command shown in the file does. `-r` is not supported,
|
|
as the image installs from the repositories of its base image. EL9,
|
|
Ubuntu 24.04 and SUSE 16 or later are supported.
|
|
|
|
* `--apptainer`:
|
|
With `--containerfile`, write an Apptainer definition file for building
|
|
a SIF instead.
|
|
|
|
* `--from` <image>:
|
|
With `--containerfile`, the base image to use instead of the default for
|
|
the OS (AlmaLinux for EL, the official Ubuntu image, openSUSE Leap for
|
|
SUSE).
|
|
|
|
* `-k`, `--kernel` <version>:
|
|
Kernel version that `uname` and `/proc` report in the image. Defaults to
|
|
the newest kernel of the image, `host` for the build system kernel. Needs
|
|
Linux 5.0 or later on x86_64 or aarch64, otherwise a warning is printed.
|
|
|
|
* <scratchdir>:
|
|
Directory to build new diskless root in. With `--containerfile`, the file
|
|
to write, or `-` for standard output.
|
|
|
|
## EXEC OPTIONS
|
|
|
|
* `-k`, `--kernel` <version>:
|
|
As for `build`. dnf keeps the newest kernel of the image as the running
|
|
one, use `-k host` to remove it.
|
|
|
|
* `-v`, `--volume` <mount>:
|
|
Directory to make available in the build environment. `-v /` will cause it to be mounted in image as `/run/external/`. `-v /:/run/root` will override the target to be `/run/root`. May be specified multiple times.
|
|
|
|
* <scratchdir>:
|
|
Directory of an unpacked diskless root.
|
|
|
|
* <cmd>:
|
|
Optional command to run (defaults to a shell). Put `--` before a
|
|
command that has options.
|
|
|
|
## UNPACK OPTIONS
|
|
|
|
* <profilename>:
|
|
The diskless OS profile to unpack.
|
|
|
|
* <scratchdir>:
|
|
Directory to extract diskless root to.
|
|
|
|
## PACK OPTIONS
|
|
|
|
* `-b`, `--baseprofile` <profile>:
|
|
Profile to copy extra info from. For example, to make a new version of an existing profile, reference the previous one as baseprofile.
|
|
|
|
* `-u`, `--unencrypted`:
|
|
Pack an unencrypted image rather than encrypting.
|
|
|
|
* <scratchdir>:
|
|
Directory containing diskless root.
|
|
|
|
* <profilename>:
|
|
The desired diskless OS profile name to pack the root into.
|
|
|
|
## CAPTURE OPTIONS
|
|
|
|
* <node>:
|
|
Node to capture image from.
|
|
|
|
* <profilename>:
|
|
Profile name for captured image.
|
|
|
|
## EXAMPLES
|
|
|
|
Build a diskless image from a distribution:
|
|
|
|
imgutil build -s alma-9.6-x86_64 /tmp/myimage
|
|
|
|
Build an aarch64 EL diskless image on an x86_64 host (the architecture is
|
|
detected from the source tree):
|
|
|
|
imgutil build -s alma-9.6-aarch64 /tmp/myimage
|
|
|
|
Build an aarch64 Ubuntu diskless image on an amd64 Ubuntu host:
|
|
|
|
imgutil build --arch aarch64 /tmp/myimage
|
|
|
|
Build from an image made from a Dockerfile and pack it:
|
|
|
|
podman build -t localhost/myimage .
|
|
imgutil build -s containers-storage:localhost/myimage /tmp/myimage
|
|
imgutil pack /tmp/myimage myprofile
|
|
|
|
Build from an image that CI pushed to a registry:
|
|
|
|
imgutil build -s docker://registry.example.com/hpc/compute:latest /tmp/myimage
|
|
|
|
Build from an Apptainer image:
|
|
|
|
imgutil build -s /var/tmp/compute.sif /tmp/myimage
|
|
|
|
Prepare an image of the build system OS in CI that builds without network
|
|
access:
|
|
|
|
imgutil build --containerfile Containerfile
|
|
podman build -t localhost/compute .
|
|
podman save -o compute.tar localhost/compute
|
|
imgutil build -s compute.tar /tmp/compute
|
|
|
|
The same for EL10 as a SIF:
|
|
|
|
imgutil build --containerfile --apptainer -s alma-10.0-x86_64 compute.def
|
|
apptainer build compute.sif compute.def
|
|
imgutil build -s compute.sif /tmp/compute
|
|
|
|
Execute a shell in an unpacked image:
|
|
|
|
imgutil exec /tmp/myimage
|
|
|
|
Execute a specific command in an image:
|
|
|
|
imgutil exec /tmp/myimage -- rpm -qa
|
|
|
|
Run an ansible playbook in an image through `imgutil exec` (chroot
|
|
connection of community.general):
|
|
|
|
cat > /usr/local/sbin/imgutil-chroot << 'EOF'
|
|
#!/bin/sh
|
|
exec /opt/confluent/bin/imgutil exec -- "$@"
|
|
EOF
|
|
chmod 755 /usr/local/sbin/imgutil-chroot
|
|
ansible-playbook -c community.general.chroot \
|
|
-e ansible_chroot_exe=/usr/local/sbin/imgutil-chroot \
|
|
-i /tmp/myimage, site.yml
|
|
|
|
Unpack an existing profile for modification:
|
|
|
|
imgutil unpack myprofile /tmp/myimage
|
|
|
|
Pack a modified image into a new profile:
|
|
|
|
imgutil pack /tmp/myimage myprofile-v2
|
|
|
|
Capture an image from a running node:
|
|
|
|
imgutil capture node01 production-image
|
|
|
|
## FILES
|
|
|
|
* `/var/lib/confluent/public/os/`:
|
|
Default location for OS profiles.
|
|
|
|
* `/var/lib/confluent/private/os/`:
|
|
Location for encrypted image keys and private data.
|
|
|
|
* `/var/lib/confluent/distributions/`:
|
|
Default location for installation sources.
|
|
|
|
## SEE ALSO
|
|
|
|
osdeploy(8)
|
|
|
|
## AUTHOR
|
|
|
|
Written for the Confluent project.
|