Debian Codegraph @

doc/source/working_with_images/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 is set as the filesystem
77 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
106 the `<type>` attributes `eficsmpart_id`, `efipart_id`,
107 `rootpart_id`, and `bootpart_id`.
108
109 Despite the customization options of the partition table shown above,
110 there are the following limitations:
111
112 1. By default, the root partition is always the last one.
113
114 Disk images built with {kiwi} are designed to be expandable.
115 For this feature to work, the partition containing the system's
116 rootfs must always be the last one. If this is unwanted for
117 some reason, {kiwi} offers an opportunity for one extra/spare
118 partition with the option to also be placed at the end of the
119 table. For details, look up `spare_part` in :ref:`image-description-elements`.
120
121 2. By default, there are no gaps in the partition table.
122
123 The way partitions are configured is done such that there are no
124 gaps in the table of the image. However, leaving some space
125 free at the **end** of the partition geometry is possible in the
126 following ways:
127
128 * **Deploy with unpartitioned free space.**
129
130 To leave space unpartitioned on the first boot of a disk image,
131 it is possible to configure an `<oem-systemsize>` that is
132 smaller than the disk the image gets deployed to. Details
133 about this setting can be found in :ref:`image-description-elements`.
134
135 * **Build with unpartitioned free space.**
136
137 To leave space unpartitioned at build time of the image, it
138 is possible to disable `<oem-resize>` and configure an
139 `<oem-systemsize>` which is smaller than the kiwi-calculated
140 disk size or the fixed setting for the disk size via the
141 `size>` element.
142
143 * **Build with unpartitioned free space.**
144
145 Setting some unpartitioned free space on the disk can be done using
146 the `unpartitioned` attribute of the `size` element in the type's section.
147 For details, see :ref:`disk-the-size-element`.
148
149 * **Resize built image adding unpartitioned free space.**
150
151 A built image can be resized by using the `kiwi-ng image resize` command
152 and setting a new extended size for the disk. See {kiwi} commands docs
153 :ref:`here <db_kiwi_image_resize>`.