Debian Codegraph @

doc/source/example_use_cases/custom_partitions.rst

raw
1 .. _custom_partitions:
2
3 Custom Disk Partitions
4 ======================
5
6 .. sidebar:: Abstract
7
8 This page provides details about the opportunities and limitations
9 of customizing the partition table in addition to the volume management
10 settings from :ref:`custom_volumes`.
11
12 {kiwi} has its own partitioning schema, which is defined according to several
13 different user configurations: boot firmware, boot partition,
14 expandable layouts, etc. Those supported features have an impact on the
15 partitioning schema.
16
17 MBR or GUID partition tables are not flexible, have limitations, and are
18 tied to some specific disk geometry. Because of that, the preferred alternative
19 to disk layouts based on traditional partition tables is using flexible
20 approaches like logical volumes.
21
22 However, under certain conditions, additional entries to the low-level
23 partition table are needed. For this purpose, the `<partitions>` section
24 exists and allows you to add custom entries, as shown in the following
25 example:
26
27 .. code:: xml
28
29 <partitions>
30 <partition name="var" size="100" mountpoint="/var" filesystem="ext3"/>
31 </partitions>
32
33 Each `<partition>` entry puts a partition of the configured size in the
34 low-level partition table, creates a filesystem on it, and includes
35 it in the system's fstab file. If parts of the root filesystem are
36 moved into their own partition, as in the above example,
37 this partition will also contain the data that gets installed during
38 the image creation process to that area.
39
40 The following attributes must/can be set to configure a partition entry:
41
42 name="identifier"
43 Mandatory name of the partition as handled by {kiwi}.
44
45 .. note::
46
47 The following reserved names cannot be used
48 because they are already represented by existing attributes:
49 `root`, `readonly`, `boot`, `prep`, `spare`, `swap`, `efi_csm`,
50 and `efi`.
51
52 partition_name="name"
53 Optional name of the partition as it appears when listing the
54 table contents with tools like `gdisk`. If no name is set,
55 {kiwi} constructs a name of the form `p.lx(identifier_from_name_attr)`.
56
57 partition_type="type_identifier"
58 Optional partition type identifier as handled by {kiwi}.
59 Allowed values are `t.linux` and `t.raid`. If not specified,
60 `t.linux` is the default.
61
62 size="size_string"
63 Mandatory size of the partition. A size string can end with `M` or
64 `G` to indicate a megabyte or gigabyte value. Without a unit
65 specification, megabyte is used.
66
67 mountpoint="path"
68 Optional mountpoint to mount the partition in the system.
69
70 filesystem="btrfs|ext2|ext3|ext4|squashfs|xfs|fat32|fat16"
71 Optional filesystem configuration to create one of the supported
72 filesystems on the partition.
73
74 label="string"
75 Optional filesystem label if a filesystem is provided. If no
76 label is specified, the `name` identifier in uppercase letters is set
77 as the filesystem label.
78
79 clone="number"
80 Optional setting to indicate that this partition should be
81 cloned `number` of times. A clone partition is content-wise an
82 exact byte-for-byte copy of the origin. However, to avoid conflicts at boot
83 time, the UUID of any cloned partition will be made unique. In the
84 sequence of partitions, the clone(s) will always be created first,
85 followed by the partition considered the origin. The origin
86 partition is the one that will be referenced and used by the
87 system.
88
89 part_id="number"
90 Specify the partition number for this partition. This is the number
91 used for the partition in the partition table. The value impacts the
92 name of the Unix device node associated with the partition. This means
93 if the disk name is, e.g., `/dev/sda` and `part_id="42"` is set, the
94 Unix node for this partition will be `/dev/sda42`. Please note that
95 the number has no impact on the geometry or order of partitions as
96 they are created. The partitions in the `<partitions>` section are still
97 created in the order in which they are listed. Please also note, if
98 custom partition IDs are used, it is strongly recommended that they
99 be used across all partitions created by kiwi. The reason for this
100 is that kiwi uses an incremental counter that, by default, matches
101 the number of the partition in the table. If custom partition
102 IDs are not used for all partitions, this results in a mix of
103 numbers, which works but is not obviously visible when reading the
104 image description. Because of that, also see the information about
105 the `<type>` attributes `eficsmpart_id`, `efipart_id`,
106 `rootpart_id`, and `bootpart_id`.
107
108 Despite the customization options of the partition table shown above,
109 there are the following limitations:
110
111 1. By default, the root partition is always the last one.
112
113 Disk images built with {kiwi} are designed to be expandable.
114 For this feature to work, the partition containing the system's
115 rootfs must always be the last one. If this is unwanted for
116 some reason, {kiwi} offers an opportunity for one extra/spare
117 partition with the option to also be placed at the end of the
118 table. For details, look up `spare_part` in :ref:`image-description-elements`.
119
120 2. By default, there are no gaps in the partition table.
121
122 The way partitions are configured is done such that there are no
123 gaps in the table of the image. However, leaving some space
124 free at the **end** of the partition geometry is possible in the
125 following ways:
126
127 * **Deploy with unpartitioned free space.**
128
129 To leave space unpartitioned on the first boot of a disk image,
130 it is possible to configure an `<oem-systemsize>` that is
131 smaller than the disk the image gets deployed to. Details
132 about this setting can be found in :ref:`image-description-elements`.
133
134 * **Build with unpartitioned free space.**
135
136 To leave space unpartitioned at build time of the image, it
137 is possible to disable `<oem-resize>` and configure an
138 `<oem-systemsize>` which is smaller than the kiwi-calculated
139 disk size or the fixed setting for the disk size via the
140 `<size>` element.
141
142 * **Build with unpartitioned free space.**
143
144 Setting some unpartitioned free space on the disk can be done using
145 the `unpartitioned` attribute of the `size` element in the type's section.
146 For details, see :ref:`disk-the-size-element`.
147
148 * **Resize built image adding unpartitioned free space.**
149
150 A built image can be resized by using the `kiwi-ng image resize` command
151 and setting a new extended size for the disk. See {kiwi} commands docs
152 :ref:`here <db_kiwi_image_resize>`.