2015-03-29 16:47:30 +00:00
|
|
|
Building An Image
|
|
|
|
=================
|
|
|
|
|
|
|
|
Now that you have diskimage-builder properly :doc:`installed <installation>`
|
|
|
|
you can get started by building your first disk image.
|
|
|
|
|
|
|
|
VM Image
|
|
|
|
--------
|
|
|
|
|
|
|
|
Our first image is going to be a bootable vm image using one of the standard
|
|
|
|
supported distribution :doc:`elements <../elements>` (Ubuntu or Fedora).
|
|
|
|
|
|
|
|
The following command will start our image build (distro must be either
|
|
|
|
'ubuntu' or 'fedora'):
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
disk-image-create <distro> vm
|
|
|
|
|
|
|
|
This will create a qcow2 file 'image.qcow2' which can then be booted.
|
|
|
|
|
2023-03-06 20:25:53 +00:00
|
|
|
Images can also be defined with YAML and built with the `diskimage-builder`.
|
|
|
|
|
|
|
|
With an `image.yaml` file containing:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- elements:
|
|
|
|
- <distro>
|
|
|
|
- vm
|
|
|
|
|
|
|
|
An image is built with:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
diskimage-builder image.yaml
|
|
|
|
|
|
|
|
Run `diskimage-builder --help` full description of the YAML attributes supported.
|
|
|
|
|
2015-03-29 16:47:30 +00:00
|
|
|
Elements
|
|
|
|
--------
|
|
|
|
|
|
|
|
It is important to note that we are passing in a list of
|
|
|
|
:doc:`elements <../elements>` to disk-image-create in our above command. Elements
|
|
|
|
are how we decide what goes into our image and what modifications will be
|
|
|
|
performed.
|
|
|
|
|
|
|
|
Some elements provide a root filesystem, such as the ubuntu or fedora element
|
|
|
|
in our example above, which other elements modify to create our image. At least
|
|
|
|
one of these 'distro elements' must be specified when performing an image
|
|
|
|
build. It's worth pointing out that there are many distro elements (you can even
|
|
|
|
create your own), and even multiples for some of the distros. This is because
|
|
|
|
there are often multiple ways to install a distro which are very different.
|
|
|
|
For example: One distro element might use a cloud image while another uses
|
|
|
|
a package installation tool to build a root filesystem for the same distro.
|
|
|
|
|
|
|
|
Other elements modify our image in some way. The 'vm' element in our example
|
|
|
|
above ensures that our image has a bootloader properly installed. This is only
|
|
|
|
needed for certain use cases and certain output formats and therefore it is
|
|
|
|
not performed by default.
|
2015-08-03 06:18:30 +00:00
|
|
|
|
|
|
|
Output Formats
|
|
|
|
--------------
|
|
|
|
|
|
|
|
By default a qcow2 image is created by the disk-image-create command. Other
|
|
|
|
output formats may be specified using the `-t <format>` argument. Multiple
|
|
|
|
output formats can also be specified by comma separation. The supported output
|
|
|
|
formats are:
|
|
|
|
|
|
|
|
* qcow2
|
|
|
|
* tar
|
2016-12-17 21:41:14 +00:00
|
|
|
* tgz
|
2016-12-18 01:59:07 +00:00
|
|
|
* squashfs
|
2015-08-03 06:18:30 +00:00
|
|
|
* vhd
|
|
|
|
* docker
|
|
|
|
* raw
|
2015-12-15 23:45:36 +00:00
|
|
|
|
2019-07-04 21:54:45 +00:00
|
|
|
When building a tgz image, note that the `DIB_GZIP_BIN` environment variable
|
|
|
|
can be used to set the path of the gzip executable.
|
|
|
|
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
Disk Image Layout
|
|
|
|
-----------------
|
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
The disk image layout (like number of images, partitions, LVM, disk
|
|
|
|
encryption) is something which should be set up during the initial
|
|
|
|
image build: it is mostly not possible to change these things later
|
|
|
|
on.
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
There are currently two defaults:
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
2018-01-30 23:56:57 +00:00
|
|
|
* When using the ``vm`` element, an element that provides
|
|
|
|
``block-device`` should be included. Available ``block-device-*``
|
|
|
|
elements cover the common case of a single partition that fills up
|
|
|
|
the whole disk and used as root device. Currently there are MBR,
|
|
|
|
GPT and EFI versions. For example, to use a GPT disk you could
|
|
|
|
build with ::
|
|
|
|
|
|
|
|
disk-image-create -o output.qcow vm block-device-gpt ubuntu-minimal
|
|
|
|
|
2023-03-06 20:25:53 +00:00
|
|
|
Or with `diskimage-builder` YAML
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- imagename: output.qcow
|
|
|
|
elements: [vm, block-device-gpt, ubuntu-minimal]
|
|
|
|
|
2018-01-30 23:56:57 +00:00
|
|
|
* When not using the ``vm`` element a plain filesystem image, without
|
2017-05-05 14:08:11 +00:00
|
|
|
any partitioning, is created.
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
2018-01-30 23:56:57 +00:00
|
|
|
If you wish to customise the top-level ``block-device-default.yaml``
|
|
|
|
file from one of the ``block-device-*`` elements, set the environment
|
2017-05-05 14:08:11 +00:00
|
|
|
variable `DIB_BLOCK_DEVICE_CONFIG`. This variable must hold YAML
|
2018-01-15 03:44:10 +00:00
|
|
|
structured configuration data or be a ``file://`` URL reference to a
|
|
|
|
on-disk configuration file.
|
2017-05-05 14:08:11 +00:00
|
|
|
|
|
|
|
There are a lot of different options for the different levels. The
|
|
|
|
following sections describe each level in detail.
|
|
|
|
|
|
|
|
General Remarks
|
|
|
|
+++++++++++++++
|
2016-07-16 20:16:13 +00:00
|
|
|
|
|
|
|
In general each module that depends on another module has a `base`
|
2017-05-05 14:08:11 +00:00
|
|
|
element that points to the depending base. Also each module has a
|
|
|
|
`name` that can be used to reference the module.
|
2016-07-16 20:16:13 +00:00
|
|
|
|
2017-05-01 10:19:26 +00:00
|
|
|
Tree-Like vs. Complete Digraph Configuration
|
|
|
|
++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
The configuration is specified as a digraph_. Each module is a
|
|
|
|
node; a edge is the relation of the current element to its `base`.
|
|
|
|
|
|
|
|
Because the general digraph_ approach is somewhat complex when it comes
|
|
|
|
to write it down, the configuration can also be given as a tree_.
|
|
|
|
|
|
|
|
.. _digraph: https://en.wikipedia.org/wiki/Directed_graph
|
|
|
|
.. _tree: https://en.wikipedia.org/wiki/Tree_(graph_theory)
|
|
|
|
|
|
|
|
Example: The tree like notation
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
mkfs:
|
|
|
|
name: root_fs
|
|
|
|
base: root_part
|
|
|
|
mount:
|
|
|
|
mount_point: /
|
|
|
|
|
|
|
|
is exactly the same as writing
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
mkfs:
|
|
|
|
name: root_fs
|
|
|
|
base: root_part
|
|
|
|
|
|
|
|
mount:
|
|
|
|
name: mount_root_fs
|
|
|
|
base: root_fs
|
2017-05-17 05:54:02 +00:00
|
|
|
mount_point: /
|
2017-05-01 10:19:26 +00:00
|
|
|
|
|
|
|
Non existing `name` and `base` entries in the tree notation are
|
|
|
|
automatically generated: the `name` is the name of the base module
|
|
|
|
prepended by the type-name of the module itself; the `base` element is
|
|
|
|
automatically set to the parent node in the tree.
|
|
|
|
|
|
|
|
In mostly all cases the much simpler tree notation can be used.
|
|
|
|
Nevertheless there are some use cases when the more general digraph
|
|
|
|
notation is needed. Example: when there is the need to combine two or
|
|
|
|
more modules into one new, like combining a couple of physical volumes
|
|
|
|
into one volume group.
|
|
|
|
|
|
|
|
Tree and digraph notations can be mixed as needed in a configuration.
|
|
|
|
|
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
Limitations
|
|
|
|
+++++++++++
|
|
|
|
|
2017-01-29 23:52:40 +00:00
|
|
|
To provide an interface towards the existing elements, there are
|
|
|
|
currently three fixed keys used - which are not configurable:
|
2016-07-16 20:16:13 +00:00
|
|
|
|
2017-01-29 23:52:40 +00:00
|
|
|
* `root-label`: this is the label of the block device that is mounted at
|
|
|
|
`/`.
|
|
|
|
* `image-block-partition`: if there is a block device with the name
|
|
|
|
`root` this is used else the block device with the name `image0` is
|
|
|
|
used.
|
|
|
|
* `image-path`: the path of the image that contains the root file
|
|
|
|
system is taken from the `image0`.
|
2016-07-16 20:16:13 +00:00
|
|
|
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
|
|
|
Level 0
|
|
|
|
+++++++
|
|
|
|
|
|
|
|
Module: Local Loop
|
|
|
|
..................
|
|
|
|
|
|
|
|
This module generates a local image file and uses the loop device to
|
|
|
|
create a block device from it. The symbolic name for this module is
|
|
|
|
`local_loop`.
|
|
|
|
|
|
|
|
Configuration options:
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the image. This is used as the name for the
|
|
|
|
image in the file system and also as a symbolic name to be able to
|
|
|
|
reference this image (e.g. to create a partition table on this
|
|
|
|
disk).
|
|
|
|
|
|
|
|
size
|
|
|
|
(optional) The size of the disk. The size can be expressed using
|
|
|
|
unit names like TiB (1024^4 bytes) or GB (1000^3 bytes).
|
|
|
|
Examples: 2.5GiB, 12KB.
|
|
|
|
If the size is not specified here, the size as given to
|
|
|
|
disk-image-create (--image-size) or the automatically computed size
|
|
|
|
is used.
|
|
|
|
|
|
|
|
directory
|
|
|
|
(optional) The directory where the image is created.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
local_loop:
|
|
|
|
name: image0
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
local_loop:
|
|
|
|
name: data_image
|
|
|
|
size: 7.5GiB
|
|
|
|
directory: /var/tmp
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
|
|
|
|
This creates two image files and uses the loop device to use them as
|
2016-07-16 20:16:13 +00:00
|
|
|
block devices. One image file called `image0` is created with
|
Refactor: block-device handling (local loop)
Block device handling can be somewhat complex - especially
when taking things like md, lvm or encryption into account.
This patch factors out the creation and deletion of the local
loop image device handling into a python library.
The main propose of this patch is to implement the needed
infrastructure. Based on this, more advanced functions can be added.
Example: (advanced) partitioning, LVM, handling different boot
scenarios (BIOS, UEFI, ...), possibility of handling multiple images
(local loop image, iSCSI, physical hard disk, ...), handling of
different filesystems for different partitions / LVs.
Change-Id: Ib626b36a00f8a5dc3dbde8df3e2619a2438eaaf1
Signed-off-by: Andreas Florath <andreas@florath.net>
2016-05-21 19:32:35 +00:00
|
|
|
default size in the default temp directory. The second image has the
|
|
|
|
size of 7.5GiB and is created in the `/var/tmp` folder.
|
|
|
|
|
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
Level 1
|
|
|
|
+++++++
|
|
|
|
|
|
|
|
Module: Partitioning
|
|
|
|
....................
|
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
This module generates partitions on existing block devices. This
|
2016-07-16 20:16:13 +00:00
|
|
|
means that it is possible to take any kind of block device (e.g. LVM,
|
|
|
|
encrypted, ...) and create partition information in it.
|
|
|
|
|
|
|
|
The symbolic name for this module is `partitioning`.
|
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
MBR
|
|
|
|
***
|
2016-07-16 20:16:13 +00:00
|
|
|
|
|
|
|
It is possible to create primary or logical partitions or a mix of
|
2017-05-05 14:08:11 +00:00
|
|
|
them. The numbering of the primary partitions will start at 1,
|
|
|
|
e.g. `/dev/vda1`; logical partitions will typically start
|
2016-07-16 20:16:13 +00:00
|
|
|
with `5`, e.g. `/dev/vda5` for the first partition, `/dev/vda6` for
|
|
|
|
the second and so on.
|
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
The number of logical partitions created by this module is theoretical
|
2016-07-16 20:16:13 +00:00
|
|
|
unlimited and it was tested with more than 1000 partitions inside one
|
|
|
|
block device. Nevertheless the Linux kernel and different tools (like
|
|
|
|
`parted`, `sfdisk`, `fdisk`) have some default maximum number of
|
|
|
|
partitions that they can handle. Please consult the documentation of
|
|
|
|
the appropriate software you plan to use and adapt the number of
|
|
|
|
partitions.
|
|
|
|
|
|
|
|
Partitions are created in the order they are configured. Primary
|
|
|
|
partitions - if needed - must be first in the list.
|
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
GPT
|
|
|
|
***
|
|
|
|
|
|
|
|
GPT partitioning requires the ``sgdisk`` tool to be available.
|
|
|
|
|
|
|
|
Options
|
|
|
|
*******
|
|
|
|
|
2017-05-05 14:08:11 +00:00
|
|
|
There are the following key / value pairs to define one partition
|
|
|
|
table:
|
2016-07-16 20:16:13 +00:00
|
|
|
|
|
|
|
base
|
2018-01-15 03:44:10 +00:00
|
|
|
(mandatory) The base device to create the partitions in.
|
2016-07-16 20:16:13 +00:00
|
|
|
|
|
|
|
label
|
2018-01-15 03:44:10 +00:00
|
|
|
(mandatory) Possible values: 'mbr', 'gpt'
|
|
|
|
Configure use of either the Master Boot Record (MBR) or GUID
|
|
|
|
Partition Table (GPT) formats
|
2016-07-16 20:16:13 +00:00
|
|
|
|
|
|
|
align
|
2018-01-15 03:44:10 +00:00
|
|
|
(optional - default value '1MiB'; MBR only)
|
2016-07-16 20:16:13 +00:00
|
|
|
Set the alignment of the partition. This must be a multiple of the
|
|
|
|
block size (i.e. 512 bytes). The default of 1MiB (~ 2048 * 512
|
|
|
|
bytes blocks) is the default for modern systems and known to
|
2017-01-29 23:52:40 +00:00
|
|
|
perform well on a wide range of targets. For each partition
|
2016-07-16 20:16:13 +00:00
|
|
|
there might be some space that is not used - which is `align` - 512
|
|
|
|
bytes. For the default of 1MiB exactly 1048064 bytes (= 1 MiB -
|
|
|
|
512 byte) are not used in the partition itself. Please note that
|
|
|
|
if a boot loader should be written to the disk or partition,
|
|
|
|
there is a need for some space. E.g. grub needs 63 * 512 byte
|
|
|
|
blocks between the MBR and the start of the partition data; this
|
|
|
|
means when grub will be installed, the `align` must be set at least
|
|
|
|
to 64 * 512 byte = 32 KiB.
|
|
|
|
|
|
|
|
partitions
|
|
|
|
(mandatory) A list of dictionaries. Each dictionary describes one
|
|
|
|
partition.
|
|
|
|
|
|
|
|
The following key / value pairs can be given for each partition:
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the partition. With the help of this name,
|
2017-05-05 14:08:11 +00:00
|
|
|
the partition can later be referenced, e.g. when creating a
|
2016-07-16 20:16:13 +00:00
|
|
|
file system.
|
|
|
|
|
|
|
|
flags
|
|
|
|
(optional) List of flags for the partition. Default: empty.
|
|
|
|
Possible values:
|
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
boot (MBR only)
|
2016-07-16 20:16:13 +00:00
|
|
|
Sets the boot flag for the partition
|
2018-01-15 03:44:10 +00:00
|
|
|
primary (MBR only)
|
2016-07-16 20:16:13 +00:00
|
|
|
Partition should be a primary partition. If not set a logical
|
|
|
|
partition will be created.
|
|
|
|
|
|
|
|
size
|
|
|
|
(mandatory) The size of the partition. The size can either be an
|
|
|
|
absolute number using units like `10GiB` or `1.75TB` or relative
|
|
|
|
(percentage) numbers: in the later case the size is calculated
|
|
|
|
based on the remaining free space.
|
|
|
|
|
2017-07-11 03:22:29 +00:00
|
|
|
type (optional)
|
2018-01-15 03:44:10 +00:00
|
|
|
The partition type stored in the MBR or GPT partition table entry.
|
|
|
|
|
|
|
|
For MBR the default value is '0x83' (Linux Default partition). Any valid one
|
2017-07-11 03:22:29 +00:00
|
|
|
byte hexadecimal value may be specified here.
|
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
For GPT the default value is '8300' (Linux Default partition). Any valid two
|
|
|
|
byte hexadecimal value may be specified here. Due to ``sgdisk`` leading '0x'
|
|
|
|
should not be used.
|
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
Example:
|
|
|
|
|
2017-03-14 00:33:01 +00:00
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- partitioning:
|
|
|
|
base: image0
|
|
|
|
label: mbr
|
|
|
|
partitions:
|
|
|
|
- name: part-01
|
|
|
|
flags: [ boot ]
|
|
|
|
size: 1GiB
|
|
|
|
- name: part-02
|
|
|
|
size: 100%
|
|
|
|
|
|
|
|
- partitioning:
|
|
|
|
base: data_image
|
|
|
|
label: mbr
|
|
|
|
partitions:
|
|
|
|
- name: data0
|
|
|
|
size: 33%
|
|
|
|
- name: data1
|
|
|
|
size: 50%
|
|
|
|
- name: data2
|
|
|
|
size: 100%
|
2016-07-16 20:16:13 +00:00
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
- partitioning:
|
|
|
|
base: gpt_image
|
|
|
|
label: gpt
|
|
|
|
partitions:
|
|
|
|
- name: ESP
|
|
|
|
type: EF00
|
|
|
|
size: 16MiB
|
|
|
|
- name: data1
|
|
|
|
size: 1GiB
|
|
|
|
- name: lvmdata
|
|
|
|
type: 8E00
|
|
|
|
size: 100%
|
|
|
|
|
2016-07-16 20:16:13 +00:00
|
|
|
On the `image0` two partitions are created. The size of the first is
|
|
|
|
1GiB, the second uses the remaining free space. On the `data_image`
|
2018-01-15 03:44:10 +00:00
|
|
|
three partitions are created: all are about 1/3 of the disk size. On
|
|
|
|
the `gpt_image` three partitions are created: 16MiB one for EFI
|
|
|
|
bootloader, 1GiB Linux filesystem one and rest of disk will be used
|
|
|
|
for LVM partition.
|
2016-07-16 20:16:13 +00:00
|
|
|
|
2018-01-15 03:44:10 +00:00
|
|
|
Module: LVM
|
|
|
|
...........
|
2017-06-08 05:02:18 +00:00
|
|
|
|
|
|
|
This module generates volumes on existing block devices. This means that it is
|
|
|
|
possible to take any previous created partition, and create volumes information
|
|
|
|
in it.
|
|
|
|
|
|
|
|
The symbolic name for this module is `lvm`.
|
|
|
|
|
|
|
|
There are the following key / value pairs to define one set of volumes:
|
|
|
|
|
|
|
|
pvs
|
|
|
|
(mandatory) A list of dictionaries. Each dictionary describes one
|
|
|
|
physical volume.
|
|
|
|
|
|
|
|
vgs
|
|
|
|
(mandatory) A list of dictionaries. Each dictionary describes one volume
|
|
|
|
group.
|
|
|
|
|
|
|
|
lvs
|
|
|
|
(mandatory) A list of dictionaries. Each dictionary describes one logical
|
|
|
|
volume.
|
|
|
|
|
|
|
|
The following key / value pairs can be given for each `pvs`:
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the physical volume. With the help of this
|
|
|
|
name, the physical volume can later be referenced, e.g. when creating
|
|
|
|
a volume group.
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name of the partition where the physical volume
|
|
|
|
needs to be created.
|
|
|
|
|
|
|
|
options
|
|
|
|
(optional) List of options for the physical volume. It can contain
|
|
|
|
any option supported by the `pvcreate` command.
|
|
|
|
|
|
|
|
The following key / value pairs can be given for each `vgs`:
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the volume group. With the help of this name,
|
|
|
|
the volume group can later be referenced, e.g. when creating a logical
|
|
|
|
volume.
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name(s) of the physical volumes where the volume groups
|
|
|
|
needs to be created. As a volume group can be created on one or more
|
|
|
|
physical volumes, this needs to be a list.
|
|
|
|
|
|
|
|
options
|
|
|
|
(optional) List of options for the volume group. It can contain any
|
|
|
|
option supported by the `vgcreate` command.
|
|
|
|
|
|
|
|
The following key / value pairs can be given for each `lvs`:
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the logical volume. With the help of this name,
|
|
|
|
the logical volume can later be referenced, e.g. when creating a
|
|
|
|
filesystem.
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name of the volume group where the logical volume
|
|
|
|
needs to be created.
|
|
|
|
|
|
|
|
size
|
|
|
|
(optional) The exact size of the volume to be created. It accepts the same
|
|
|
|
syntax as the -L flag of the `lvcreate` command.
|
|
|
|
|
|
|
|
extents
|
|
|
|
(optional) The relative size in extents of the volume to be created. It
|
|
|
|
accepts the same syntax as the -l flag of the `lvcreate` command.
|
|
|
|
Either size or extents need to be passed on the volume creation.
|
|
|
|
|
|
|
|
options
|
|
|
|
(optional) List of options for the logical volume. It can contain any
|
|
|
|
option supported by the `lvcreate` command.
|
|
|
|
|
2022-05-01 23:37:48 +00:00
|
|
|
type
|
|
|
|
(optional) When set to `thin-pool` a thin pool volume will be created. When
|
|
|
|
set to `thin` the thin volume will be backed by the thin pool named with the
|
|
|
|
`thin-pool` key.
|
|
|
|
|
|
|
|
thin-pool
|
|
|
|
(optional) Name of the thin pool to use for this thin volume.
|
|
|
|
|
2017-06-08 05:02:18 +00:00
|
|
|
Example:
|
|
|
|
|
2018-02-12 13:26:02 +00:00
|
|
|
.. code-block:: yaml
|
2017-06-08 05:02:18 +00:00
|
|
|
|
|
|
|
- lvm:
|
|
|
|
name: lvm
|
|
|
|
pvs:
|
|
|
|
- name: pv
|
|
|
|
options: ["--force"]
|
2020-12-16 19:18:21 +00:00
|
|
|
base: root
|
2017-06-08 05:02:18 +00:00
|
|
|
|
|
|
|
vgs:
|
|
|
|
- name: vg
|
|
|
|
base: ["pv"]
|
|
|
|
options: ["--force"]
|
|
|
|
|
|
|
|
lvs:
|
|
|
|
- name: lv_root
|
|
|
|
base: vg
|
|
|
|
size: 1800M
|
|
|
|
|
|
|
|
- name: lv_tmp
|
|
|
|
base: vg
|
|
|
|
size: 100M
|
|
|
|
|
|
|
|
- name: lv_var
|
|
|
|
base: vg
|
|
|
|
size: 500M
|
|
|
|
|
|
|
|
- name: lv_log
|
|
|
|
base: vg
|
|
|
|
size: 100M
|
|
|
|
|
|
|
|
- name: lv_audit
|
|
|
|
base: vg
|
|
|
|
size: 100M
|
|
|
|
|
|
|
|
- name: lv_home
|
|
|
|
base: vg
|
|
|
|
size: 200M
|
|
|
|
|
|
|
|
On the `root` partition a physical volume is created. On that physical
|
|
|
|
volume, a volume group is created. On top of this volume group, six logical
|
|
|
|
volumes are created.
|
|
|
|
|
2017-09-11 12:23:26 +00:00
|
|
|
Please note that in order to build images that are bootable using volumes,
|
|
|
|
your ramdisk image will need to have that support. If the image you are using
|
|
|
|
does not have it, you can add the needed modules and regenerate it, by
|
|
|
|
including the `dracut-regenerate` element when building it.
|
|
|
|
|
2017-01-29 23:52:40 +00:00
|
|
|
|
|
|
|
Level 2
|
|
|
|
+++++++
|
|
|
|
|
|
|
|
Module: Mkfs
|
|
|
|
............
|
|
|
|
|
|
|
|
This module creates file systems on the block device given as `base`.
|
|
|
|
The following key / value pairs can be given:
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name of the block device where the filesystem will
|
|
|
|
be created on.
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the partition. This can be used to
|
|
|
|
reference (e.g. mounting) the filesystem.
|
|
|
|
|
|
|
|
type
|
|
|
|
(mandatory) The type of the filesystem, like `ext4` or `xfs`.
|
|
|
|
|
|
|
|
label
|
|
|
|
(optional - defaults to the name)
|
|
|
|
The label of the filesystem. This can be used e.g. by grub or in
|
|
|
|
the fstab.
|
|
|
|
|
|
|
|
opts
|
|
|
|
(optional - defaults to empty list)
|
|
|
|
Options that will passed to the mkfs command.
|
|
|
|
|
|
|
|
uuid
|
|
|
|
(optional - no default / not used if not givem)
|
|
|
|
The UUID of the filesystem. Not all file systems might
|
|
|
|
support this. Currently there is support for `ext2`, `ext3`,
|
|
|
|
`ext4` and `xfs`.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- mkfs:
|
|
|
|
name: mkfs_root
|
|
|
|
base: root
|
|
|
|
type: ext4
|
|
|
|
label: cloudimage-root
|
|
|
|
uuid: b733f302-0336-49c0-85f2-38ca109e8bdb
|
|
|
|
opts: "-i 16384"
|
|
|
|
|
|
|
|
|
|
|
|
Level 3
|
|
|
|
+++++++
|
|
|
|
|
|
|
|
Module: Mount
|
|
|
|
.............
|
|
|
|
|
|
|
|
This module mounts a filesystem. The options are:
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name of the filesystem that will be mounted.
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the mount point. This can be used for
|
|
|
|
reference the mount (e.g. creating the fstab).
|
|
|
|
|
|
|
|
mount_point
|
|
|
|
(mandatory) The mount point of the filesystem.
|
|
|
|
|
|
|
|
There is no need to list the mount points in the correct order: an
|
|
|
|
algorithm will automatically detect the mount order.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- mount:
|
|
|
|
name: root_mnt
|
|
|
|
base: mkfs_root
|
|
|
|
mount_point: /
|
|
|
|
|
|
|
|
|
|
|
|
Level 4
|
|
|
|
+++++++
|
|
|
|
|
|
|
|
Module: fstab
|
|
|
|
.............
|
|
|
|
|
|
|
|
This module creates fstab entries. The following options exists. For
|
|
|
|
details please consult the fstab man page.
|
|
|
|
|
|
|
|
base
|
|
|
|
(mandatory) The name of the mount point that will be written to
|
|
|
|
fstab.
|
|
|
|
|
|
|
|
name
|
|
|
|
(mandatory) The name of the fstab entry. This can be used later on
|
|
|
|
as reference - and is currently unused.
|
|
|
|
|
|
|
|
options
|
|
|
|
(optional, defaults to `default`)
|
|
|
|
Special mount options can be given. This is used as the fourth
|
|
|
|
field in the fstab entry.
|
|
|
|
|
|
|
|
dump-freq
|
|
|
|
(optional, defaults to 0 - don't dump)
|
|
|
|
This is passed to dump to determine which filesystem should be
|
|
|
|
dumped. This is used as the fifth field in the fstab entry.
|
|
|
|
|
|
|
|
fsck-passno
|
|
|
|
(optional, defaults to 2)
|
|
|
|
Determines the order to run fsck. Please note that this should be
|
|
|
|
set to 1 for the root file system. This is used as the sixth field
|
|
|
|
in the fstab entry.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
- fstab:
|
|
|
|
name: var_log_fstab
|
|
|
|
base: var_log_mnt
|
|
|
|
options: nodev,nosuid
|
|
|
|
dump-freq: 2
|
|
|
|
|
|
|
|
|
2019-04-29 06:05:00 +00:00
|
|
|
Legacy global filesystem configuration
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
The ``disk-image-create`` tool has a number of historic global
|
|
|
|
disk-related command-line options which are maintained for backwards
|
|
|
|
compatibility. These options are merged as necessary by the
|
|
|
|
block-device layer into the active configuration. If you are using
|
|
|
|
more complicated block-device layouts with multiple partitions, you
|
|
|
|
may need to take into account the special behaviour described below.
|
|
|
|
|
|
|
|
The ``local_loop`` module will take it's default size from the
|
2019-04-23 12:30:48 +00:00
|
|
|
following arguments:
|
2019-04-29 06:05:00 +00:00
|
|
|
|
|
|
|
``--image-size``
|
|
|
|
The size of loopback device which the image will be generated in,
|
|
|
|
in gigabytes. If this is left unset, the size will be calculated
|
|
|
|
from the on-disk size of the image and then scaled up by a fixed
|
|
|
|
60% factor. Can also set ``DIB_IMAGE_SIZE``.
|
|
|
|
|
2019-04-23 12:30:48 +00:00
|
|
|
``--image-extra-size``
|
|
|
|
Extra space to add when automatically calculating image size, in
|
2019-05-07 17:32:50 +00:00
|
|
|
megabytes. This overrides the default 60% scale up as described
|
2019-04-23 12:30:48 +00:00
|
|
|
above for ``--image-size``. Can also set ``DIB_IMAGE_EXTRA_SIZE``.
|
|
|
|
|
2019-04-29 06:05:00 +00:00
|
|
|
The special node named ``mkfs_root`` is affected by the following;
|
|
|
|
this reflects that the standard layout has only a single root
|
|
|
|
partition so the options are, in effect, global for the default
|
|
|
|
configuration. Note that if you are using multiple partitions,
|
|
|
|
settings such as ``--mkfs-options`` will *not* apply to other
|
|
|
|
partitions.
|
2016-12-08 04:59:15 +00:00
|
|
|
|
2019-04-29 06:05:00 +00:00
|
|
|
The file-system type for the ``mkfs_root`` node is set by the
|
|
|
|
``FS_TYPE`` environment variable, and defaults to ``ext4``. ``xfs``
|
|
|
|
should also work. There is no command-line argument for this.
|
|
|
|
|
|
|
|
The following options also affect the ``mkfs_root`` node
|
|
|
|
configuration:
|
|
|
|
|
|
|
|
``--mkfs-options``
|
|
|
|
Options passed to mkfs when making the root partition. For
|
|
|
|
``ext4`` partitions, this by default sets a 4k byte-to-inode ratio
|
|
|
|
(see below) and a default journal size of 64MiB. Note
|
|
|
|
``--mkfs-options`` are options passed to the mfks *driver*
|
|
|
|
(i.e. ``mkfs.ext4``) rather than ``mkfs`` itself (i.e. arguments
|
|
|
|
come after the initial ``mkfs -t <fstype>`` argument). You also
|
|
|
|
need to be careful with quoting. Can also set ``MKFS_OPTS``.
|
|
|
|
|
|
|
|
By default, ``disk-image-create`` uses a 4k byte-to-inode ratio
|
|
|
|
when creating the filesystem in the image. This allows large
|
|
|
|
'whole-system' images to utilize several TB disks without
|
|
|
|
exhausting inodes. In contrast, when creating images intended for
|
|
|
|
tenant instances, this ratio consumes more disk space than an
|
|
|
|
end-user would expect (e.g. a 50GB root disk has 47GB available).
|
|
|
|
If the image is intended to run within a tens to hundrededs of
|
|
|
|
gigabyte disk, setting the byte-to-inode ratio to the ext4 default
|
|
|
|
of 16k will allow for more usable space on the instance. The
|
|
|
|
default can be overridden by passing ``'-i 16384'`` as a
|
|
|
|
``--mkfs-options`` argument.
|
|
|
|
|
2019-01-26 20:02:54 +00:00
|
|
|
``--mkfs-journal-size``
|
|
|
|
Only valid for ``FS_TYPE==ext4``. This value set the filesystem
|
|
|
|
journal size in MB; overriding the default of 64MiB. Note the
|
|
|
|
image size will be grown to fit the journal, unless
|
|
|
|
``DIB_IMAGE_SIZE`` is explicitly set. Can also set
|
|
|
|
``DIB_JOURNAL_SIZE``.
|
|
|
|
|
2019-04-29 06:05:00 +00:00
|
|
|
``--max-online-resize``
|
|
|
|
Only valid for ``FS_TYPE==ext4``; this value sets the maximum
|
|
|
|
filesystem blocks when resizing. Can also set
|
|
|
|
``MAX_ONLINE_RESIZE``.
|
|
|
|
|
|
|
|
``--root-label``
|
|
|
|
The file-system label specified when creating the root file system.
|
|
|
|
Defaults to ``cloudimg-rootfs`` for ``ext4`` and ``img-rootfs`` for
|
|
|
|
``xfs``. Can also set ``ROOT_LABEL``.
|
2016-12-08 04:59:15 +00:00
|
|
|
|
2016-01-17 11:38:59 +00:00
|
|
|
Speedups
|
|
|
|
--------
|
|
|
|
If you have 4GB of available physical RAM (as reported by /proc/meminfo
|
|
|
|
MemTotal), or more, diskimage-builder will create a tmpfs mount to build the
|
|
|
|
image in. This will improve image build time by building it in RAM.
|
|
|
|
By default, the tmpfs file system uses 50% of the available RAM.
|
|
|
|
Therefore, the RAM should be at least the double of the minimum tmpfs
|
|
|
|
size required.
|
2017-06-26 03:24:06 +00:00
|
|
|
|
2016-01-17 11:38:59 +00:00
|
|
|
For larger images, when no sufficient amount of RAM is available, tmpfs
|
|
|
|
can be disabled completely by passing --no-tmpfs to disk-image-create.
|
|
|
|
ramdisk-image-create builds a regular image and then within that image
|
|
|
|
creates ramdisk.
|
2017-06-26 03:24:06 +00:00
|
|
|
|
2016-01-17 11:38:59 +00:00
|
|
|
If tmpfs is not used, you will need enough room in /tmp to store two
|
|
|
|
uncompressed cloud images. If tmpfs is used, you would still need /tmp space
|
|
|
|
for one uncompressed cloud image and about 20% of that image for working files.
|
2017-01-29 23:52:40 +00:00
|
|
|
|
2018-04-03 05:20:42 +00:00
|
|
|
Nameservers
|
|
|
|
-----------
|
|
|
|
|
|
|
|
To ensure elements can access the network, ``disk-image-create``
|
|
|
|
replaces the ``/etc/resolv.conf`` within the chroot with a copy of the
|
|
|
|
host's file early in the image creation process.
|
|
|
|
|
|
|
|
The final ``/etc/resolv.conf`` can be controlled in a number of ways.
|
|
|
|
If, during the build, the ``/etc/resolv.conf`` file within the chroot
|
|
|
|
is replaced with a symlink, this will be retained in the final image
|
|
|
|
[1]_. If the file is marked immutable, it will also not be touched.
|
|
|
|
|
|
|
|
.. [1] This somewhat odd case was added for installation of the
|
|
|
|
``resolvconf`` package, which replaces ``/etc/resolv.conf``
|
|
|
|
with a symlink to it's version. Depending on its contents, and
|
|
|
|
what comes after the installation in the build, this mostly
|
|
|
|
works.
|
|
|
|
|
|
|
|
If you would like specific contents within the final
|
|
|
|
``/etc/resolv.conf`` you can place them into
|
|
|
|
``/etc/resolv.conf.ORIG`` during the build. As one of the final
|
|
|
|
steps, this file will be ``mv`` to ``/etc/resolv.conf``.
|
|
|
|
|
2017-06-26 03:24:06 +00:00
|
|
|
|
|
|
|
Chosing an Architecture
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
If needed you can specify an override the architecture selection by passing a
|
|
|
|
``-a`` argument like:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
disk-image-create -a <arch> ...
|
|
|
|
|
|
|
|
Notes about PowerPC Architectures
|
|
|
|
+++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
PowerPC can operate in either Big or Little Endian mode. ``ppc64``
|
|
|
|
always refers to Big Endian operation. When running in little endian
|
|
|
|
mode it can be referred to as ``ppc64le`` or ``ppc64el``.
|
|
|
|
|
|
|
|
Typically ``ppc64el`` refers to a ``.deb`` based distribution
|
|
|
|
architecture, and ``ppc64le`` refers to a ``.rpm`` based distribution.
|
|
|
|
Regardless of the distribution the kernel architecture is always
|
|
|
|
``ppc64le``.
|
2017-05-11 03:09:42 +00:00
|
|
|
|
|
|
|
Notes about s390x (z Systems) Architecture
|
|
|
|
++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
Images for s390x can only be build on s390x hosts. Trying to build
|
|
|
|
it with the architecture override on other architecture will
|
|
|
|
cause the build to fail.
|
|
|
|
|