VIRT-BOOTSTRAP(1)

๐Ÿ“ฆ
version 1.1.1 ยท 2 versions
, in fedora 43

๐ŸŽ€ NAME ๐ŸŽ€

virt-bootstrap โ€” Setup root file system for libvirt-based containers. That's the whole assignment and it ate, no crumbs. ๐Ÿ’…โœจ


โœจ SYNOPSIS โœจ

virt-bootstrap URI DEST [OPTIONS]

you hand it a URI and a DEST and it simply goes off. ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so virt-bootstrap is a tool providing an easy way to setup the root file system for libvirt-based containers. It allows you to use either a tarball containing the file system, an image on a docker registry or a virt-builder template, and unpacks it either as a folder or in a

๐ŸŒˆ Supported sources are: ๐ŸŒˆ

  • file:///path/to/rootfs.tar โ€” tar archive which contains root file system
  • docker://registry:port/image:tag โ€” Docker registry
  • virt-builder://template โ€” virt-builder templates

Docker container images are downloaded and the layers are getting cached. If virt-bootstrap is running with effective UID=0 (root) the layersq are cached in /var/cache/virt-bootstrap/docker_images. For unprivileged users the ~/.cache/virt-bootstrap/docker_images directory is used. If the environment variable XDG_CACHE_HOME is specified then this directory is used instead of ~/.cache. ๐Ÿ—‚๏ธ

The environment variable VIRTBOOTSTRAP_TMPDIR can be used to specify temporary directory used by virt-bootstrap or default /tmp will be used. ๐ŸŒก๏ธ


โญ OPTIONS โญ

  • -f, --format โ€” output format of the root file system. Possible values are dir (the default, bestie) and qcow2. ๐Ÿ“
  • --root-password SELECTOR โ€” this argument will generate a hash from ROOT_PASSWORD, gotten from the SELECTOR field, and insert the hashed value into /etc/shadow in the created root file system. Note that SELECTOR can be one of the following: file:. If the output format is qcow2 these modifications are applied in an additional qcow2 disk image.
Note that the /etc/shadow file must already exist in the extracted root file system of the container image and it must have an entry for root user. no entry, no password glow-up, periodt. ๐Ÿ˜ญ
  • --no-cache โ€” when this flag is used Docker images will be downloaded in a temporary directory and discarded after the root file system is extracted. gone, deleted, never spoken of again. ๐Ÿ’€
  • --status-only โ€” if this flag is used the log messages will be suppresses and only information about the current progress will be displayed. ๐Ÿ“Š
  • -q, --quiet โ€” show only warning and error messages. ๐Ÿคซ
  • -d, --debug โ€” show debugging output messages. ๐Ÿ”
  • -h, --help โ€” display command line help summary. ๐Ÿ†˜
  • --version โ€” show virt-bootstrap's version number and exit. ๐Ÿ‘‘

๐Ÿ” Authentication options for accessing private Docker registry ๐Ÿ”

Note: if --username argument is specified and --password omitted, a password prompt will be issued. If --username is omitted the --password argument will be ignored. the math is mathing, bestie. ๐Ÿงฎ
  • -u, --username USERNAME โ€” this argument takes USERNAME to be used to access Docker source registry. ๐Ÿชช
  • -p, --password PASSWORD โ€” this argument takes PASSWORD to be used to access Docker source registry. ๐Ÿ”‘
  • --not-secure โ€” don't require HTTPS and verification of certificates when talking to Docker registry. see skopeo copy in skopeo(1). lowkey risky but you do you. ๐Ÿ™ˆ

๐Ÿ‘‘ UID/GID mapping ๐Ÿ‘‘

  • --uidmap start:target:count โ€” shift UIDs of all root file system entries with some offset. This parameter can be specified multiple times. Example: --uidmap 0:1000:10 --uidmap 500:1500:10 โ€” this will map the UIDs: 0-9 to 1000-1009 and 500-509 to 1500-1509. See INSTALLATION OPTIONS in virt-install(1).
  • --gidmap start:target:count โ€” shift GIDs of all root file system entries with some offset. This parameter can be specified multiple times. Example: --gidmap 0:1000:10 --gidmap 500:1500:10 โ€” this will map the GIDs: 0-9 to 1000-1009 and 500-509 to 1500-1509. See INSTALLATION OPTIONS in virt-install(1).
  • --idmap start:target:count โ€” remapping owner and group of all files and directories inside of the root file system. This parameter can be specified multiple times. Example: --idmap 0:1000:10 --idmap 500:1500:10 โ€” this will map UIDs and GIDs: 0-9 to 1000-1009 and 500-509 to 1500-1509. See INSTALLATION OPTIONS in virt-install(1).

๐ŸŒˆ USAGE EXAMPLES ๐ŸŒˆ

Create root file system using Ubuntu image docker.io registry:

$ virt-bootstrap docker://ubuntu /tmp/foo

Create root file system from image stored on private Docker registry:

$ virt-bootstrap docker://localhost:5000/ubuntu /tmp/foo \
  --username testuser \
  --password testpassoword \
  --not-secure

Apply UIDs/GIDs mapping for root file system entries

$ virt-bootstrap docker://fedora /tmp/foo \
  --idmap 0:1000:10

This above command will map UIDs/GIDs: 0-9 to 1000-1009

The same result can be achieved with:

$ virt-bootstrap docker://fedora /tmp/foo \
  --uidmap 0:1000:10 \
  --gidmap 0:1000:10

Multiple mapping values can be specified as follows:

$ virt_bootstrap.py docker://ubuntu /tmp/foo \
  --idmap 0:1000:10 \
  --idmap 500:1500:10

This will map the UID/GIDs: 0-9 to 1000-1009 and 500-509 to 1500-1509

Set root password

$ virt_bootstrap.py docker://opensuse /tmp/foo \
  --root-password file:/tmp/secret

The above command will download the opensuse container image and extract the root file system to /tmp/foo. Then it will generate hash of the password present in /tmp/secret file and insert it into /tmp/foo/etc/shadow file. ๐ŸŽ€

$ virt_bootstrap.py docker://opensuse /tmp/foo \
  --root-password file:/tmp/secret \
  -f qcow2

Similarly for qcow2 format the container image will be downloaded and the root file system will be extracted into qcow2 disk images with backing chains. Then additional qcow2 image will be created with backing file set to the last layer and the modification of shadow file will be applied there. layers upon layers, it's giving onion but make it iconic. ๐Ÿง…


๐Ÿ’œ AUTHOR ๐Ÿ’œ

Written by Cedric Bosdonnat and Radostin Stoyanov. absolute legends, we stan. ๐Ÿซถ


and that's the whole page bestie ๐Ÿ’– this one is from virt-bootstrap 1.1.1, dated 2025-09-19, and it lives in the VIRT-BOOTSTRAP(1) manual. mwah ๐Ÿ’‹

๐Ÿ“ฆ where this page comes from