2023-02-16 12:07:00 +01:00
|
|
|
# How to build images
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
## Plain rootfs
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
$ distrobuilder build-dir --help
|
|
|
|
|
Build plain rootfs
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
distrobuilder build-dir <filename|-> <target dir> [flags]
|
|
|
|
|
|
|
|
|
|
Flags:
|
2023-04-21 09:09:09 +02:00
|
|
|
-h, --help help for build-dir
|
|
|
|
|
--keep-sources Keep sources after build (default true)
|
|
|
|
|
--sources-dir Sources directory for distribution tarballs (default "/tmp/distrobuilder")
|
|
|
|
|
--with-post-files Run post-files actions
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
Global Flags:
|
2021-09-16 10:05:09 +02:00
|
|
|
--cache-dir Cache directory
|
|
|
|
|
--cleanup Clean up cache directory (default true)
|
|
|
|
|
--debug Enable debug output
|
|
|
|
|
--disable-overlay Disable the use of filesystem overlays
|
|
|
|
|
-o, --options Override options (list of key=value)
|
|
|
|
|
-t, --timeout Timeout in seconds
|
|
|
|
|
--version Print version number
|
|
|
|
|
|
2019-08-26 21:51:06 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To build a plain rootfs, run `distrobuilder build-dir`.
|
|
|
|
|
The command takes an image definition file and an output directory as positional arguments.
|
2023-09-05 17:24:58 -04:00
|
|
|
Running `build-dir` is useful if one wants to build both LXC and Incus images.
|
2019-08-26 21:51:06 +02:00
|
|
|
In that case one can simply run
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
distrobuilder build-dir def.yaml /path/to/rootfs
|
|
|
|
|
distrobuilder pack-lxc def.yaml /path/to/rootfs /path/to/output
|
2023-09-05 17:11:41 -04:00
|
|
|
distrobuilder pack-incus def.yaml /path/to/rootfs /path/to/output
|
2019-08-26 21:51:06 +02:00
|
|
|
```
|
|
|
|
|
|
2023-06-21 18:04:23 +02:00
|
|
|
(howto-build-lxc)=
|
2019-08-26 21:51:06 +02:00
|
|
|
## LXC image
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
$ distrobuilder build-lxc --help
|
|
|
|
|
Build LXC image from scratch
|
|
|
|
|
|
2021-09-16 10:05:09 +02:00
|
|
|
The compression can be set with the --compression flag. I can take one of the
|
|
|
|
|
following values:
|
|
|
|
|
- bzip2
|
|
|
|
|
- gzip
|
|
|
|
|
- lzip
|
|
|
|
|
- lzma
|
2022-12-02 16:39:43 +11:00
|
|
|
- lzo
|
2021-09-16 10:05:09 +02:00
|
|
|
- lzop
|
|
|
|
|
- xz (default)
|
|
|
|
|
- zstd
|
|
|
|
|
|
2022-11-29 14:23:35 +11:00
|
|
|
For supported compression methods, a compression level can be specified with
|
|
|
|
|
method-N, where N is an integer, e.g. gzip-9.
|
|
|
|
|
|
2019-08-26 21:51:06 +02:00
|
|
|
Usage:
|
2021-09-16 10:05:09 +02:00
|
|
|
distrobuilder build-lxc <filename|-> [target dir] [--compression=COMPRESSION] [flags]
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
Flags:
|
2021-10-28 13:34:44 +02:00
|
|
|
--compression Type of compression to use (default "xz")
|
|
|
|
|
-h, --help help for build-lxc
|
|
|
|
|
--keep-sources Keep sources after build (default true)
|
|
|
|
|
--sources-dir Sources directory for distribution tarballs (default "/tmp/distrobuilder")
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
Global Flags:
|
2021-09-16 10:05:09 +02:00
|
|
|
--cache-dir Cache directory
|
|
|
|
|
--cleanup Clean up cache directory (default true)
|
|
|
|
|
--debug Enable debug output
|
|
|
|
|
--disable-overlay Disable the use of filesystem overlays
|
|
|
|
|
-o, --options Override options (list of key=value)
|
|
|
|
|
-t, --timeout Timeout in seconds
|
|
|
|
|
--version Print version number
|
|
|
|
|
|
2019-08-26 21:51:06 +02:00
|
|
|
```
|
|
|
|
|
|
2023-02-16 15:30:03 +01:00
|
|
|
Running the `build-lxc` sub-command creates a LXC image.
|
2019-08-26 21:51:06 +02:00
|
|
|
It outputs two files `rootfs.tar.xz` and `meta.tar.xz`.
|
|
|
|
|
After building the image, the rootfs will be destroyed.
|
|
|
|
|
|
2023-02-16 15:30:03 +01:00
|
|
|
The `pack-lxc` sub-command can be used to create an image from an existing rootfs.
|
2019-08-26 21:51:06 +02:00
|
|
|
The rootfs won't be deleted afterwards.
|
|
|
|
|
|
2023-09-05 17:11:05 -04:00
|
|
|
(howto-build-incus)=
|
2023-09-05 17:24:58 -04:00
|
|
|
## Incus image
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
```shell
|
2023-09-05 17:11:05 -04:00
|
|
|
$ distrobuilder build-incus --help
|
2023-09-05 17:24:58 -04:00
|
|
|
Build Incus image from scratch
|
2019-08-26 21:51:06 +02:00
|
|
|
|
2021-09-16 10:05:09 +02:00
|
|
|
Depending on the type, it either outputs a unified (single tarball)
|
|
|
|
|
or split image (tarball + squashfs or qcow2 image). The --type flag can take one of the
|
|
|
|
|
following values:
|
|
|
|
|
- split (default)
|
|
|
|
|
- unified
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The compression can be set with the --compression flag. I can take one of the
|
|
|
|
|
following values:
|
|
|
|
|
- bzip2
|
|
|
|
|
- gzip
|
|
|
|
|
- lzip
|
|
|
|
|
- lzma
|
2022-12-02 16:39:43 +11:00
|
|
|
- lzo
|
2021-09-16 10:05:09 +02:00
|
|
|
- lzop
|
|
|
|
|
- xz (default)
|
|
|
|
|
- zstd
|
|
|
|
|
|
2022-11-29 14:23:35 +11:00
|
|
|
For supported compression methods, a compression level can be specified with
|
|
|
|
|
method-N, where N is an integer, e.g. gzip-9.
|
|
|
|
|
|
2019-08-26 21:51:06 +02:00
|
|
|
Usage:
|
2023-09-05 17:24:58 -04:00
|
|
|
distrobuilder build-incus <filename|-> [target dir] [--type=TYPE] [--compression=COMPRESSION] [--import-into-incus] [flags]
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
Flags:
|
2023-09-05 17:24:58 -04:00
|
|
|
--compression Type of compression to use (default "xz")
|
|
|
|
|
-h, --help help for build-incus
|
|
|
|
|
--import-into-incus[="-"] Import built image into Incus
|
|
|
|
|
--keep-sources Keep sources after build (default true)
|
|
|
|
|
--sources-dir Sources directory for distribution tarballs (default "/tmp/distrobuilder")
|
|
|
|
|
--type Type of tarball to create (default "split")
|
|
|
|
|
--vm Create a qcow2 image for VMs
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
Global Flags:
|
2021-09-16 10:05:09 +02:00
|
|
|
--cache-dir Cache directory
|
|
|
|
|
--cleanup Clean up cache directory (default true)
|
|
|
|
|
--debug Enable debug output
|
|
|
|
|
--disable-overlay Disable the use of filesystem overlays
|
|
|
|
|
-o, --options Override options (list of key=value)
|
|
|
|
|
-t, --timeout Timeout in seconds
|
|
|
|
|
--version Print version number
|
2019-08-26 21:51:06 +02:00
|
|
|
```
|
|
|
|
|
|
2023-09-05 17:24:58 -04:00
|
|
|
Running the `build-incus` sub-command creates an Incus image.
|
2020-05-25 13:00:29 +02:00
|
|
|
If `--type=split`, it outputs two files.
|
2023-09-05 16:54:35 -04:00
|
|
|
The metadata tarball will always be named `incus.tar.xz`.
|
2020-05-25 13:00:29 +02:00
|
|
|
When creating a container image, the second file will be `rootfs.squashfs`.
|
|
|
|
|
When creating a VM image, the second file will be `disk.qcow2`.
|
2019-08-26 21:51:06 +02:00
|
|
|
If `--type=unified`, a unified tarball named `<image.name>.tar.xz` is created.
|
2023-02-16 12:07:00 +01:00
|
|
|
See the [image section](../reference/image.md) for more on the image name.
|
2019-08-26 21:51:06 +02:00
|
|
|
|
|
|
|
|
If `--compression` is set, the tarballs will use the provided compression instead of `xz`.
|
|
|
|
|
|
2023-02-16 15:30:03 +01:00
|
|
|
Setting `--vm` will create a `qcow2` image which is used for virtual machines.
|
2025-03-28 18:15:32 +01:00
|
|
|
This requires some extra tools to be installed on your host - see [How to
|
|
|
|
|
install `distrobuilder`](install.md) for instructions.
|
2021-03-23 10:59:02 +01:00
|
|
|
|
2023-09-05 17:24:58 -04:00
|
|
|
If `--import-into-incus` is set, the resulting image is imported into Incus.
|
2021-09-16 10:05:09 +02:00
|
|
|
It basically runs `lxc image import <image>`.
|
|
|
|
|
Per default, it doesn't create an alias.
|
2023-09-05 17:24:58 -04:00
|
|
|
This can be changed by calling it as `--import-into-incus=<alias>`.
|
2021-09-16 10:05:09 +02:00
|
|
|
|
2019-08-26 21:51:06 +02:00
|
|
|
After building the image, the rootfs will be destroyed.
|
|
|
|
|
|
2023-09-05 17:11:41 -04:00
|
|
|
The `pack-incus` sub-command can be used to create an image from an existing rootfs.
|
2019-08-26 21:51:06 +02:00
|
|
|
The rootfs won't be deleted afterwards.
|