1REPART.D(5) repart.d REPART.D(5)
2
3
4
6 repart.d - Partition Definition Files for Automatic Boot-Time
7 Repartitioning
8
10 /etc/repart.d/*.conf
11 /run/repart.d/*.conf
12 /usr/lib/repart.d/*.conf
13
14
16 repart.d/*.conf files describe basic properties of partitions of block
17 devices of the local system. They may be used to declare types, names
18 and sizes of partitions that shall exist. The systemd-repart(8) service
19 reads these files and attempts to add new partitions currently missing
20 and enlarge existing partitions according to these definitions.
21 Operation is generally incremental, i.e. when applied, what exists
22 already is left intact, and partitions are never shrunk, moved or
23 deleted.
24
25 These definition files are useful for implementing operating system
26 images that are prepared and delivered with minimally sized images (for
27 example lacking any state or swap partitions), and which on first boot
28 automatically take possession of any remaining disk space following a
29 few basic rules.
30
31 Currently, support for partition definition files is only implemented
32 for GPT partitition tables.
33
34 Partition files are generally matched against any partitions already
35 existing on disk in a simple algorithm: the partition files are sorted
36 by their filename (ignoring the directory prefix), and then compared in
37 order against existing partitions matching the same partition type
38 UUID. Specifically, the first existing partition with a specific
39 partition type UUID is assigned the first definition file with the same
40 partition type UUID, and the second existing partition with a specific
41 type UUID the second partition file with the same type UUID, and so on.
42 Any left-over partition files that have no matching existing partition
43 are assumed to define new partition that shall be created. Such
44 partitions are appended to the end of the partition table, in the order
45 defined by their names utilizing the first partition slot greater than
46 the highest slot number currently in use. Any existing partitions that
47 have no matching partition file are left as they are.
48
49 Note that these partition definition files do not describe the contents
50 of the partitions, such as the file system used. Separate mechanisms,
51 such as systemd-growfs(8) and systemd-makefs maybe be used to
52 initialize or grow the file systems inside of these partitions.
53
55 Type=
56 The GPT partition type UUID to match. This may be a GPT partition
57 type UUID such as 4f68bce3-e8cd-4db1-96e7-fbcaf984b709, or one of
58 the following special identifiers:
59
60 Table 1. GPT partition type identifiers
61 ┌──────────────────────┬────────────────────────────┐
62 │Identifier │ Explanation │
63 ├──────────────────────┼────────────────────────────┤
64 │esp │ EFI System Partition │
65 ├──────────────────────┼────────────────────────────┤
66 │xbootldr │ Extended Boot Loader │
67 │ │ Partition │
68 ├──────────────────────┼────────────────────────────┤
69 │swap │ Swap partition │
70 ├──────────────────────┼────────────────────────────┤
71 │home │ Home (/home/) partition │
72 ├──────────────────────┼────────────────────────────┤
73 │srv │ Server data (/srv/) │
74 │ │ partition │
75 ├──────────────────────┼────────────────────────────┤
76 │var │ Variable data (/var/) │
77 │ │ partition │
78 ├──────────────────────┼────────────────────────────┤
79 │tmp │ Temporary data (/var/tmp/) │
80 │ │ partition │
81 ├──────────────────────┼────────────────────────────┤
82 │linux-generic │ Generic Linux file system │
83 │ │ partition │
84 ├──────────────────────┼────────────────────────────┤
85 │root │ Root file system partition │
86 │ │ type appropriate for the │
87 │ │ local architecture (an │
88 │ │ alias for an architecture │
89 │ │ root file system partition │
90 │ │ type listed below, e.g. │
91 │ │ root-x86-64) │
92 ├──────────────────────┼────────────────────────────┤
93 │root-verity │ Verity data for the root │
94 │ │ file system partition for │
95 │ │ the local architecture │
96 ├──────────────────────┼────────────────────────────┤
97 │root-secondary │ Root file system partition │
98 │ │ of the secondary │
99 │ │ architecture of the local │
100 │ │ architecture; usually the │
101 │ │ matching 32bit │
102 │ │ architecture for the local │
103 │ │ 64bit architecture) │
104 ├──────────────────────┼────────────────────────────┤
105 │root-secondary-verity │ Verity data for the root │
106 │ │ file system partition of │
107 │ │ the secondary architecture │
108 ├──────────────────────┼────────────────────────────┤
109 │root-x86 │ Root file system partition │
110 │ │ for the x86 (32bit, aka │
111 │ │ i386) architecture │
112 ├──────────────────────┼────────────────────────────┤
113 │root-x86-verity │ Verity data for the x86 │
114 │ │ (32bit) root file system │
115 │ │ partition │
116 ├──────────────────────┼────────────────────────────┤
117 │root-x86-64 │ Root file system partition │
118 │ │ for the x86_64 (64bit, aka │
119 │ │ amd64) architecture │
120 ├──────────────────────┼────────────────────────────┤
121 │root-x86-64-verity │ Verity data for the x86_64 │
122 │ │ (64bit) root file system │
123 │ │ partition │
124 ├──────────────────────┼────────────────────────────┤
125 │root-arm │ Root file system partition │
126 │ │ for the ARM (32bit) │
127 │ │ architecture │
128 ├──────────────────────┼────────────────────────────┤
129 │root-arm-verity │ Verity data for the ARM │
130 │ │ (32bit) root file system │
131 │ │ partition │
132 ├──────────────────────┼────────────────────────────┤
133 │root-arm64 │ Root file system partition │
134 │ │ for the ARM (64bit, aka │
135 │ │ aarch64) architecture │
136 ├──────────────────────┼────────────────────────────┤
137 │root-arm64-verity │ Verity data for the ARM │
138 │ │ (64bit, aka aarch64) root │
139 │ │ file system partition │
140 ├──────────────────────┼────────────────────────────┤
141 │root-ia64 │ Root file system partition │
142 │ │ for the ia64 architecture │
143 ├──────────────────────┼────────────────────────────┤
144 │root-ia64-verity │ Verity data for the ia64 │
145 │ │ root file system partition │
146 └──────────────────────┴────────────────────────────┘
147 This setting defaults to linux-generic.
148
149 Most of the partition type UUIDs listed above are defined in the
150 Discoverable Partitions Specification[1].
151
152 Label=
153 The textual label to assign to the partition if none is assigned
154 yet. Note that this setting is not used for matching. It is also
155 not used when a label is already set for an existing partition. It
156 is thus only used when a partition is newly created or when an
157 existing one had a no label set (that is: an empty label). If not
158 specified a label derived from the partition type is automatically
159 used.
160
161 Priority=
162 A numeric priority to assign to this partition, in the range
163 -2147483648...2147483647, with smaller values indicating higher
164 priority, and higher values indicating smaller priority. This
165 priority is used in case the configured size constraints on the
166 defined partitions do not permit fitting all partitions onto the
167 available disk space. If the partitions do not fit, the highest
168 numeric partition priority of all defined partitions is determined,
169 and all defined partitions with this priority are removed from the
170 list of new partitions to create (which may be multiple, if the
171 same priority is used for multiple partitions). The fitting
172 algorithm is then tried again. If the partitions still do not fit,
173 the now highest numeric partition priority is determined, and the
174 matching partitions removed too, and so on. Partitions of a
175 priority of 0 or lower are never removed. If all partitions with a
176 priority above 0 are removed and the partitions still do not fit on
177 the device the operation fails. Note that this priority has no
178 effect on ordering partitions, for that use the alphabetical order
179 of the filenames of the partition definition files. Defaults to 0.
180
181 Weight=
182 A numeric weight to assign to this partition in the range
183 0...1000000. Available disk space is assigned the defined
184 partitions according to their relative weights (subject to the size
185 constraints configured with SizeMinBytes=, SizeMaxBytes=), so that
186 a partition with weight 2000 gets double the space as one with
187 weight 1000, and a partition with weight 333 a third of that.
188 Defaults to 1000.
189
190 The Weight= setting is used to distribute available disk space in
191 an "elastic" fashion, based on the disk size and existing
192 partitions. If a partition shall have a fixed size use both
193 SizeMinBytes= and SizeMaxBytes= with the same value in order to
194 fixate the size to one value, in which case the weight has no
195 effect.
196
197 PaddingWeight=
198 Similar to Weight= but sets a weight for the free space after the
199 partition (the "padding"). When distributing available space the
200 weights of all partitions and all defined padding is summed, and
201 then each partition and padding gets the fraction defined by its
202 weight. Defaults to 0, i.e. by default no padding is applied.
203
204 Padding is useful if empty space shall be left for later additions
205 or a safety margin at the end of the device or between partitions.
206
207 SizeMinBytes=, SizeMaxBytes=
208 Specifies minimum and maximum size constraints in bytes. Takes the
209 usual K, M, G, T, ... suffixes (to the base of 1024). If
210 SizeMinBytes= is specified the partition is created at or grown to
211 at least the specified size. If SizeMaxBytes= is specified the
212 partition is created at or grown to at most the specified size. The
213 precise size is determined through the weight value value
214 configured with Weight=, see above. When SizeMinBytes= is set equal
215 to SizeMaxBytes= the configured weight has no effect as the
216 partition is explicitly sized to the specified fixed value. Note
217 that partitions are never created smaller than 4096 bytes, and
218 since partitions are never shrunk the previous size of the
219 partition (in case the partition already exists) is also enforced
220 as lower bound for the new size. The values should be specified as
221 multiples of 4096 bytes, and are rounded upwards (in case of
222 SizeMinBytes=) or downwards (in case of SizeMaxBytes=) otherwise.
223 If the backing device does not provide enough space to fulfill the
224 constraints placing the partition will fail. For partitions that
225 shall be created, depending on the setting of Priority= (see above)
226 the partition might be dropped and the placing algorithm restarted.
227 By default no size constraints are set.
228
229 PaddingMinBytes=, PaddingMaxBytes=
230 Specifies minimum and maximum size constrains in bytes for the free
231 space after the partition (the "padding"). Semantics are similar to
232 SizeMinBytes= and SizeMaxBytes=, except that unlike partition sizes
233 free space can be shrunk and can be as small as zero. By default no
234 size constraints on padding are set, so that only PaddingWeight=
235 determines the size of the padding applied.
236
237 FactoryReset=
238 Takes a boolean argument. If specified the partition is marked for
239 removal during a factory reset operation. This functionality is
240 useful to implement schemes where images can be reset into their
241 original state by removing partitions and creating them anew.
242 Defaults to off.
243
245 Example 1. Grow the root partition to the full disk size at first boot
246
247 With the following file the root partition is automatically grown to
248 the full disk if possible during boot.
249
250 # /usr/lib/repart.d/50-root.conf
251 [Partition]
252 Type=root
253
254
255 Example 2. Create a swap and home partition automatically on boot, if
256 missing
257
258 The home partition gets all available disk space while the swap
259 partition gets 1G at most and 64M at least. We set a priority > 0 on
260 the swap partition to ensure the swap partition is not used if not
261 enough space is available. For every three bytes assigned to the home
262 partition the swap partition gets assigned one.
263
264 # /usr/lib/repart.d/60-home.conf
265 [Partition]
266 Type=home
267
268 # /usr/lib/repart.d/70-swap.conf
269 [Partition]
270 Type=swap
271 SizeMinBytes=64M
272 SizeMaxBytes=1G
273 Priority=1
274 Weight=333
275
276
277 Example 3. Create B partitions in an A/B Verity setup, if missing
278
279 Let's say the vendor intends to update OS images in an A/B setup, i.e.
280 with two root partitions (and two matching Verity partitions) that
281 shall be used alternatingly during upgrades. To minimize image sizes
282 the original image is shipped only with one root and one Verity
283 partition (the "A" set), and the second root and Verity partitions (the
284 "B" set) shall be created on first boot on the free space on the
285 medium.
286
287 # /usr/lib/repart.d/50-root.conf
288 [Partition]
289 Type=root
290 SizeMinBytes=512M
291 SizeMaxBytes=512M
292
293 # /usr/lib/repart.d/60-root-verity.conf
294 [Partition]
295 Type=root-verity
296 SizeMinBytes=64M
297 SizeMaxBytes=64M
298
299 The definitions above cover the "A" set of root partition (of a fixed
300 512M size) and Verity partition for the root partition (of a fixed 64M
301 size). Let's use symlinks to create the "B" set of partitions, since
302 after all they shall have the same properties and sizes as the "A" set.
303
304 # ln -s 50-root.conf /usr/lib/repart.d/70-root-b.conf
305 # ln -s 60-root-verity.conf /usr/lib/repart.d/80-root-verity-b.conf
306
307
309 systemd(1), systemd-repart(8), sfdisk(8)
310
312 1. Discoverable Partitions Specification
313 https://systemd.io/DISCOVERABLE_PARTITIONS
314
315
316
317systemd 245 REPART.D(5)