]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/repart.d.xml
Merge pull request #20303 from andir/sysconfig-example
[thirdparty/systemd.git] / man / repart.d.xml
CommitLineData
917cc808
LP
1<?xml version='1.0'?>
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
e031166e
LP
4<refentry id="repart.d" conditional='ENABLE_REPART'
5 xmlns:xi="http://www.w3.org/2001/XInclude">
917cc808
LP
6
7 <refentryinfo>
8 <title>repart.d</title>
9 <productname>systemd</productname>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>repart.d</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>repart.d</refname>
19 <refpurpose>Partition Definition Files for Automatic Boot-Time Repartitioning</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para><literallayout><filename>/etc/repart.d/*.conf</filename>
24<filename>/run/repart.d/*.conf</filename>
25<filename>/usr/lib/repart.d/*.conf</filename>
26 </literallayout></para>
27 </refsynopsisdiv>
28
29 <refsect1>
30 <title>Description</title>
31
32 <para><filename>repart.d/*.conf</filename> files describe basic properties of partitions of block
33 devices of the local system. They may be used to declare types, names and sizes of partitions that shall
34 exist. The
35 <citerefentry><refentrytitle>systemd-repart</refentrytitle><manvolnum>8</manvolnum></citerefentry>
36 service reads these files and attempts to add new partitions currently missing and enlarge existing
37 partitions according to these definitions. Operation is generally incremental, i.e. when applied, what
38 exists already is left intact, and partitions are never shrunk, moved or deleted.</para>
39
40 <para>These definition files are useful for implementing operating system images that are prepared and
41 delivered with minimally sized images (for example lacking any state or swap partitions), and which on
42 first boot automatically take possession of any remaining disk space following a few basic rules.</para>
43
44 <para>Currently, support for partition definition files is only implemented for GPT partitition
45 tables.</para>
46
47 <para>Partition files are generally matched against any partitions already existing on disk in a simple
48 algorithm: the partition files are sorted by their filename (ignoring the directory prefix), and then
49 compared in order against existing partitions matching the same partition type UUID. Specifically, the
50 first existing partition with a specific partition type UUID is assigned the first definition file with
51 the same partition type UUID, and the second existing partition with a specific type UUID the second
52 partition file with the same type UUID, and so on. Any left-over partition files that have no matching
53 existing partition are assumed to define new partition that shall be created. Such partitions are
54 appended to the end of the partition table, in the order defined by their names utilizing the first
55 partition slot greater than the highest slot number currently in use. Any existing partitions that have
56 no matching partition file are left as they are.</para>
57
1c41c1dc 58 <para>Note that these definitions may only be used to create and initialize new partitions or to grow
dfb4d0ae
LP
59 existing ones. In the latter case it will not grow the contained files systems however; separate
60 mechanisms, such as
61 <citerefentry><refentrytitle>systemd-growfs</refentrytitle><manvolnum>8</manvolnum></citerefentry> may be
1c41c1dc
LP
62 used to grow the file systems inside of these partitions. Partitions may also be marked for automatic
63 growing via the <varname>GrowFileSystem=</varname> setting, in which case the file system is grown on
64 first mount by tools that respect this flag. See below for details.</para>
917cc808
LP
65 </refsect1>
66
67 <refsect1>
68 <title>[Partition] Section Options</title>
69
70 <variablelist>
71 <varlistentry>
72 <term><varname>Type=</varname></term>
73
74 <listitem><para>The GPT partition type UUID to match. This may be a GPT partition type UUID such as
75 <constant>4f68bce3-e8cd-4db1-96e7-fbcaf984b709</constant>, or one of the following special
76 identifiers:</para>
77
78 <table>
79 <title>GPT partition type identifiers</title>
80
81 <tgroup cols='2' align='left' colsep='1' rowsep='1'>
82 <colspec colname="name" />
83 <colspec colname="explanation" />
84
85 <thead>
86 <row>
87 <entry>Identifier</entry>
88 <entry>Explanation</entry>
89 </row>
90 </thead>
91
92 <tbody>
93 <row>
94 <entry><constant>esp</constant></entry>
95 <entry>EFI System Partition</entry>
96 </row>
97
98 <row>
99 <entry><constant>xbootldr</constant></entry>
100 <entry>Extended Boot Loader Partition</entry>
101 </row>
102
103 <row>
104 <entry><constant>swap</constant></entry>
105 <entry>Swap partition</entry>
106 </row>
107
108 <row>
109 <entry><constant>home</constant></entry>
110 <entry>Home (<filename>/home/</filename>) partition</entry>
111 </row>
112
113 <row>
114 <entry><constant>srv</constant></entry>
115 <entry>Server data (<filename>/srv/</filename>) partition</entry>
116 </row>
117
118 <row>
119 <entry><constant>var</constant></entry>
120 <entry>Variable data (<filename>/var/</filename>) partition</entry>
121 </row>
122
123 <row>
124 <entry><constant>tmp</constant></entry>
125 <entry>Temporary data (<filename>/var/tmp/</filename>) partition</entry>
126 </row>
127
128 <row>
129 <entry><constant>linux-generic</constant></entry>
130 <entry>Generic Linux file system partition</entry>
131 </row>
132
133 <row>
134 <entry><constant>root</constant></entry>
135 <entry>Root file system partition type appropriate for the local architecture (an alias for an architecture root file system partition type listed below, e.g. <constant>root-x86-64</constant>)</entry>
136 </row>
137
138 <row>
139 <entry><constant>root-verity</constant></entry>
140 <entry>Verity data for the root file system partition for the local architecture</entry>
141 </row>
142
143 <row>
144 <entry><constant>root-secondary</constant></entry>
f4e1a425 145 <entry>Root file system partition of the secondary architecture of the local architecture (usually the matching 32bit architecture for the local 64bit architecture)</entry>
917cc808
LP
146 </row>
147
148 <row>
149 <entry><constant>root-secondary-verity</constant></entry>
150 <entry>Verity data for the root file system partition of the secondary architecture</entry>
151 </row>
152
153 <row>
154 <entry><constant>root-x86</constant></entry>
155 <entry>Root file system partition for the x86 (32bit, aka i386) architecture</entry>
156 </row>
157
158 <row>
159 <entry><constant>root-x86-verity</constant></entry>
160 <entry>Verity data for the x86 (32bit) root file system partition</entry>
161 </row>
162
163 <row>
164 <entry><constant>root-x86-64</constant></entry>
165 <entry>Root file system partition for the x86_64 (64bit, aka amd64) architecture</entry>
166 </row>
167
168 <row>
169 <entry><constant>root-x86-64-verity</constant></entry>
170 <entry>Verity data for the x86_64 (64bit) root file system partition</entry>
171 </row>
172
173 <row>
174 <entry><constant>root-arm</constant></entry>
175 <entry>Root file system partition for the ARM (32bit) architecture</entry>
176 </row>
177
178 <row>
179 <entry><constant>root-arm-verity</constant></entry>
180 <entry>Verity data for the ARM (32bit) root file system partition</entry>
181 </row>
182
183 <row>
184 <entry><constant>root-arm64</constant></entry>
185 <entry>Root file system partition for the ARM (64bit, aka aarch64) architecture</entry>
186 </row>
187
188 <row>
189 <entry><constant>root-arm64-verity</constant></entry>
190 <entry>Verity data for the ARM (64bit, aka aarch64) root file system partition</entry>
191 </row>
192
193 <row>
194 <entry><constant>root-ia64</constant></entry>
195 <entry>Root file system partition for the ia64 architecture</entry>
196 </row>
197
198 <row>
199 <entry><constant>root-ia64-verity</constant></entry>
200 <entry>Verity data for the ia64 root file system partition</entry>
201 </row>
329cde79 202
4e767154
WX
203 <row>
204 <entry><constant>root-loongarch64</constant></entry>
205 <entry>Root file system partition for the LoongArch 64-bit architecture</entry>
206 </row>
207
208 <row>
209 <entry><constant>root-loongarch64-verity</constant></entry>
210 <entry>Verity data for the LoongArch 64-bit root file system partition</entry>
211 </row>
212
499f0f82
DJL
213 <row>
214 <entry><constant>root-riscv32</constant></entry>
215 <entry>Root file system partition for the RISC-V 32-bit architecture</entry>
216 </row>
217
218 <row>
219 <entry><constant>root-riscv32-verity</constant></entry>
220 <entry>Verity data for the RISC-V 32-bit root file system partition</entry>
221 </row>
222
223 <row>
224 <entry><constant>root-riscv64</constant></entry>
225 <entry>Root file system partition for the RISC-V 64-bit architecture</entry>
226 </row>
227
228 <row>
229 <entry><constant>root-riscv64-verity</constant></entry>
230 <entry>Verity data for the RISC-V 64-bit root file system partition</entry>
231 </row>
232
329cde79
LP
233 <row>
234 <entry><constant>usr</constant></entry>
235 <entry><filename>/usr/</filename> file system partition type appropriate for the local architecture (an alias for an architecture <filename>/usr/</filename> file system partition type listed below, e.g. <constant>usr-x86-64</constant>)</entry>
236 </row>
237
238 <row>
239 <entry><constant>usr-verity</constant></entry>
240 <entry>Verity data for the <filename>/usr/</filename> file system partition for the local architecture</entry>
241 </row>
242
243 <row>
244 <entry><constant>usr-secondary</constant></entry>
245 <entry><filename>/usr/</filename> file system partition of the secondary architecture of the local architecture (usually the matching 32bit architecture for the local 64bit architecture)</entry>
246 </row>
247
248 <row>
249 <entry><constant>usr-secondary-verity</constant></entry>
250 <entry>Verity data for the <filename>/usr/</filename> file system partition of the secondary architecture</entry>
251 </row>
252
253 <row>
254 <entry><constant>usr-x86</constant></entry>
255 <entry><filename>/usr/</filename> file system partition for the x86 (32bit, aka i386) architecture</entry>
256 </row>
257
258 <row>
259 <entry><constant>usr-x86-verity</constant></entry>
260 <entry>Verity data for the x86 (32bit) <filename>/usr/</filename> file system partition</entry>
261 </row>
262
263 <row>
264 <entry><constant>usr-x86-64</constant></entry>
265 <entry><filename>/usr/</filename> file system partition for the x86_64 (64bit, aka amd64) architecture</entry>
266 </row>
267
268 <row>
269 <entry><constant>usr-x86-64-verity</constant></entry>
270 <entry>Verity data for the x86_64 (64bit) <filename>/usr/</filename> file system partition</entry>
271 </row>
272
273 <row>
274 <entry><constant>usr-arm</constant></entry>
275 <entry><filename>/usr/</filename> file system partition for the ARM (32bit) architecture</entry>
276 </row>
277
278 <row>
279 <entry><constant>usr-arm-verity</constant></entry>
280 <entry>Verity data for the ARM (32bit) <filename>/usr/</filename> file system partition</entry>
281 </row>
282
283 <row>
284 <entry><constant>usr-arm64</constant></entry>
285 <entry><filename>/usr/</filename> file system partition for the ARM (64bit, aka aarch64) architecture</entry>
286 </row>
287
288 <row>
289 <entry><constant>usr-arm64-verity</constant></entry>
290 <entry>Verity data for the ARM (64bit, aka aarch64) <filename>/usr/</filename> file system partition</entry>
291 </row>
292
293 <row>
294 <entry><constant>usr-ia64</constant></entry>
295 <entry><filename>/usr/</filename> file system partition for the ia64 architecture</entry>
296 </row>
297
298 <row>
299 <entry><constant>usr-ia64-verity</constant></entry>
300 <entry>Verity data for the ia64 <filename>/usr/</filename> file system partition</entry>
301 </row>
499f0f82 302
4e767154
WX
303 <row>
304 <entry><constant>usr-loongarch64</constant></entry>
305 <entry><filename>/usr/</filename> file system partition for the LoongArch 64-bit architecture</entry>
306 </row>
307
308 <row>
309 <entry><constant>usr-loongarch64-verity</constant></entry>
310 <entry>Verity data for the LoongArch 64-bit <filename>/usr/</filename> file system partition</entry>
311 </row>
312
499f0f82
DJL
313 <row>
314 <entry><constant>usr-riscv32</constant></entry>
315 <entry><filename>/usr/</filename> file system partition for the RISC-V 32-bit architecture</entry>
316 </row>
317
318 <row>
319 <entry><constant>usr-riscv32-verity</constant></entry>
320 <entry>Verity data for the RISC-V 32-bit <filename>/usr/</filename> file system partition</entry>
321 </row>
322
323 <row>
324 <entry><constant>usr-riscv64</constant></entry>
325 <entry><filename>/usr/</filename> file system partition for the RISC-V 64-bit architecture</entry>
326 </row>
327
328 <row>
329 <entry><constant>usr-riscv64-verity</constant></entry>
330 <entry>Verity data for the RISC-V 64-bit <filename>/usr/</filename> file system partition</entry>
331 </row>
917cc808
LP
332 </tbody>
333 </tgroup>
334 </table>
335
336 <para>This setting defaults to <constant>linux-generic</constant>.</para>
337
338 <para>Most of the partition type UUIDs listed above are defined in the <ulink
339 url="https://systemd.io/DISCOVERABLE_PARTITIONS">Discoverable Partitions
340 Specification</ulink>.</para></listitem>
341 </varlistentry>
342
343 <varlistentry>
344 <term><varname>Label=</varname></term>
345
346 <listitem><para>The textual label to assign to the partition if none is assigned yet. Note that this
347 setting is not used for matching. It is also not used when a label is already set for an existing
348 partition. It is thus only used when a partition is newly created or when an existing one had a no
349 label set (that is: an empty label). If not specified a label derived from the partition type is
e031166e 350 automatically used. Simple specifier expansion is supported, see below.</para></listitem>
917cc808
LP
351 </varlistentry>
352
12963533
TH
353 <varlistentry>
354 <term><varname>UUID=</varname></term>
355
356 <listitem><para>The UUID to assign to the partition if none is assigned yet. Note that this
357 setting is not used for matching. It is also not used when a UUID is already set for an existing
358 partition. It is thus only used when a partition is newly created or when an existing one had a
359 all-zero UUID set. If not specified a UUID derived from the partition type is automatically
360 used.</para></listitem>
361 </varlistentry>
362
917cc808
LP
363 <varlistentry>
364 <term><varname>Priority=</varname></term>
365
366 <listitem><para>A numeric priority to assign to this partition, in the range -2147483648…2147483647,
367 with smaller values indicating higher priority, and higher values indicating smaller priority. This
368 priority is used in case the configured size constraints on the defined partitions do not permit
369 fitting all partitions onto the available disk space. If the partitions do not fit, the highest
370 numeric partition priority of all defined partitions is determined, and all defined partitions with
371 this priority are removed from the list of new partitions to create (which may be multiple, if the
372 same priority is used for multiple partitions). The fitting algorithm is then tried again. If the
373 partitions still do not fit, the now highest numeric partition priority is determined, and the
374 matching partitions removed too, and so on. Partitions of a priority of 0 or lower are never
375 removed. If all partitions with a priority above 0 are removed and the partitions still do not fit on
376 the device the operation fails. Note that this priority has no effect on ordering partitions, for
377 that use the alphabetical order of the filenames of the partition definition files. Defaults to
378 0.</para></listitem>
379 </varlistentry>
380
381 <varlistentry>
382 <term><varname>Weight=</varname></term>
383
384 <listitem><para>A numeric weight to assign to this partition in the range 0…1000000. Available disk
385 space is assigned the defined partitions according to their relative weights (subject to the size
386 constraints configured with <varname>SizeMinBytes=</varname>, <varname>SizeMaxBytes=</varname>), so
387 that a partition with weight 2000 gets double the space as one with weight 1000, and a partition with
388 weight 333 a third of that. Defaults to 1000.</para>
389
390 <para>The <varname>Weight=</varname> setting is used to distribute available disk space in an
391 "elastic" fashion, based on the disk size and existing partitions. If a partition shall have a fixed
392 size use both <varname>SizeMinBytes=</varname> and <varname>SizeMaxBytes=</varname> with the same
393 value in order to fixate the size to one value, in which case the weight has no
394 effect.</para></listitem>
395 </varlistentry>
396
397 <varlistentry>
398 <term><varname>PaddingWeight=</varname></term>
399
400 <listitem><para>Similar to <varname>Weight=</varname> but sets a weight for the free space after the
401 partition (the "padding"). When distributing available space the weights of all partitions and all
402 defined padding is summed, and then each partition and padding gets the fraction defined by its
403 weight. Defaults to 0, i.e. by default no padding is applied.</para>
404
405 <para>Padding is useful if empty space shall be left for later additions or a safety margin at the
406 end of the device or between partitions.</para></listitem>
407 </varlistentry>
408
409 <varlistentry>
410 <term><varname>SizeMinBytes=</varname></term>
411 <term><varname>SizeMaxBytes=</varname></term>
412
413 <listitem><para>Specifies minimum and maximum size constraints in bytes. Takes the usual K, M, G, T,
414 … suffixes (to the base of 1024). If <varname>SizeMinBytes=</varname> is specified the partition is
415 created at or grown to at least the specified size. If <varname>SizeMaxBytes=</varname> is specified
416 the partition is created at or grown to at most the specified size. The precise size is determined
417 through the weight value value configured with <varname>Weight=</varname>, see above. When
418 <varname>SizeMinBytes=</varname> is set equal to <varname>SizeMaxBytes=</varname> the configured
419 weight has no effect as the partition is explicitly sized to the specified fixed value. Note that
420 partitions are never created smaller than 4096 bytes, and since partitions are never shrunk the
421 previous size of the partition (in case the partition already exists) is also enforced as lower bound
422 for the new size. The values should be specified as multiples of 4096 bytes, and are rounded upwards
423 (in case of <varname>SizeMinBytes=</varname>) or downwards (in case of
424 <varname>SizeMaxBytes=</varname>) otherwise. If the backing device does not provide enough space to
425 fulfill the constraints placing the partition will fail. For partitions that shall be created,
426 depending on the setting of <varname>Priority=</varname> (see above) the partition might be dropped
fb08381c
LP
427 and the placing algorithm restarted. By default a minimum size constraint of 10M and no maximum size
428 constraint is set.</para></listitem>
917cc808
LP
429 </varlistentry>
430
431 <varlistentry>
432 <term><varname>PaddingMinBytes=</varname></term>
433 <term><varname>PaddingMaxBytes=</varname></term>
434
757bc2e4 435 <listitem><para>Specifies minimum and maximum size constraints in bytes for the free space after the
917cc808
LP
436 partition (the "padding"). Semantics are similar to <varname>SizeMinBytes=</varname> and
437 <varname>SizeMaxBytes=</varname>, except that unlike partition sizes free space can be shrunk and can
438 be as small as zero. By default no size constraints on padding are set, so that only
439 <varname>PaddingWeight=</varname> determines the size of the padding applied.</para></listitem>
440 </varlistentry>
441
757bc2e4
LP
442 <varlistentry>
443 <term><varname>CopyBlocks=</varname></term>
444
5c08da58
LP
445 <listitem><para>Takes a path to a regular file, block device node or directory, or the special value
446 <literal>auto</literal>. If specified and the partition is newly created, the data from the specified
447 path is written to the newly created partition, on the block level. If a directory is specified, the
448 backing block device of the file system the directory is on is determined, and the data read directly
449 from that. This option is useful to efficiently replicate existing file systems onto new partitions
450 on the block level — for example to build a simple OS installer or an OS image builder.</para>
451
452 <para>If the special value <literal>auto</literal> is specified, the source to copy from is
453 automatically picked up from the running system (or the image specified with
454 <option>--image=</option> — if used). A partition that matches both the configured partition type (as
be0d27ee
ZJS
455 declared with <varname>Type=</varname> described above), and the currently mounted directory
456 appropriate for that partition type is determined. For example, if the partition type is set to
5c08da58
LP
457 <literal>root</literal> the partition backing the root directory (<filename>/</filename>) is used as
458 source to copy from — if its partition type is set to <literal>root</literal> as well. If the
459 declared type is <literal>usr</literal> the partition backing <filename>/usr/</filename> is used as
460 source to copy blocks from — if its partition type is set to <literal>usr</literal> too. The logic is
3d62af7d 461 capable of automatically tracking down the backing partitions for encrypted and Verity-enabled
5c08da58
LP
462 volumes. <literal>CopyBlocks=auto</literal> is useful for implementing "self-replicating" systems,
463 i.e. systems that are their own installer.</para>
757bc2e4
LP
464
465 <para>The file specified here must have a size that is a multiple of the basic block size 512 and not
466 be empty. If this option is used, the size allocation algorithm is slightly altered: the partition is
467 created as least as big as required to fit the data in, i.e. the data size is an additional minimum
468 size value taken into consideration for the allocation algorithm, similar to and in addition to the
469 <varname>SizeMin=</varname> value configured above.</para>
470
471 <para>This option has no effect if the partition it is declared for already exists, i.e. existing
472 data is never overwritten. Note that the data is copied in before the partition table is updated,
473 i.e. before the partition actually is persistently created. This provides robustness: it is
474 guaranteed that the partition either doesn't exist or exists fully populated; it is not possible that
dfb4d0ae
LP
475 the partition exists but is not or only partially populated.</para>
476
477 <para>This option cannot be combined with <varname>Format=</varname> or
478 <varname>CopyFiles=</varname>.</para></listitem>
479 </varlistentry>
480
481 <varlistentry>
482 <term><varname>Format=</varname></term>
483
484 <listitem><para>Takes a file system name, such as <literal>ext4</literal>, <literal>btrfs</literal>,
485 <literal>xfs</literal> or <literal>vfat</literal>, or the special value <literal>swap</literal>. If
486 specified and the partition is newly created it is formatted with the specified file system (or as
487 swap device). The file system UUID and label are automatically derived from the partition UUID and
488 label. If this option is used, the size allocation algorithm is slightly altered: the partition is
489 created as least as big as required for the minimal file system of the specified type (or 4KiB if the
490 minimal size is not known).</para>
491
492 <para>This option has no effect if the partition already exists.</para>
493
494 <para>Similar to the behaviour of <varname>CopyBlocks=</varname> the file system is formatted before
495 the partition is created, ensuring that the partition only ever exists with a fully initialized
496 file system.</para>
497
498 <para>This option cannot be combined with <varname>CopyBlocks=</varname>.</para></listitem>
499 </varlistentry>
500
501 <varlistentry>
502 <term><varname>CopyFiles=</varname></term>
503
504 <listitem><para>Takes a pair of colon separated absolute file system paths. The first path refers to
505 a source file or directory on the host, the second path refers to a target in the file system of the
506 newly created partition and formatted file system. This setting may be used to copy files or
507 directories from the host into the file system that is created due to the <varname>Format=</varname>
508 option. If <varname>CopyFiles=</varname> is used without <varname>Format=</varname> specified
509 explicitly, <literal>Format=</literal> with a suitable default is implied (currently
510 <literal>ext4</literal>, but this may change in the future). This option may be used multiple times
511 to copy multiple files or directories from host into the newly formatted file system. The colon and
512 second path may be omitted in which case the source path is also used as the target path (relative to
513 the root of the newly created file system). If the source path refers to a directory it is copied
514 recursively.</para>
515
516 <para>This option has no effect if the partition already exists: it cannot be used to copy additional
517 files into an existing partition, it may only be used to populate a file system created anew.</para>
518
519 <para>The copy operation is executed before the file system is registered in the partition table,
520 thus ensuring that a file system populated this way only ever exists fully initialized.</para>
521
252d6267
LP
522 <para>This option cannot be combined with <varname>CopyBlocks=</varname>.</para>
523
524 <para>When <command>systemd-repart</command> is invoked with the <option>--image=</option> or
525 <option>--root=</option> command line switches the source paths specified are taken relative to the
526 specified root directory or disk image root.</para></listitem>
dfb4d0ae
LP
527 </varlistentry>
528
d83d8048
LP
529 <varlistentry>
530 <term><varname>MakeDirectories=</varname></term>
531
be0d27ee 532 <listitem><para>Takes one or more absolute paths, separated by whitespace, each declaring a directory
d83d8048
LP
533 to create within the new file system. Behaviour is similar to <varname>CopyFiles=</varname>, but
534 instead of copying in a set of files this just creates the specified directories with the default
535 mode of 0755 owned by the root user and group, plus all their parent directories (with the same
536 ownership and access mode). To configure directories with different ownership or access mode, use
537 <varname>CopyFiles=</varname> and specify a source tree to copy containing appropriately
538 owned/configured directories. This option may be used more than once to create multiple
539 directories. When <varname>CopyFiles=</varname> and <varname>MakeDirectories=</varname> are used
540 together the former is applied first. If a directory listed already exists no operation is executed
541 (in particular, the ownership/access mode of the directories is left as is).</para>
542
543 <para>The primary usecase for this option is to create a minimal set of directories that may be
544 mounted over by other partitions contained in the same disk image. For example, a disk image where
545 the root file system is formatted at first boot might want to automatically pre-create
546 <filename>/usr/</filename> in it this way, so that the <literal>usr</literal> partition may
547 over-mount it.</para>
548
549 <para>Consider using
550 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>
551 with its <option>--image=</option> option to pre-create other, more complex directory hierarchies (as
552 well as other inodes) with fine-grained control of ownership, access modes and other file
553 attributes.</para></listitem>
554 </varlistentry>
555
dfb4d0ae
LP
556 <varlistentry>
557 <term><varname>Encrypt=</varname></term>
558
cf1e172d
LP
559 <listitem><para>Takes one of <literal>off</literal>, <literal>key-file</literal>,
560 <literal>tpm2</literal> and <literal>key-file+tpm2</literal> (alternatively, also accepts a boolean
561 value, which is mapped to <literal>off</literal> when false, and <literal>key-file</literal> when
562 true). Defaults to <literal>off</literal>. If not <literal>off</literal> the partition will be
dfb4d0ae
LP
563 formatted with a LUKS2 superblock, before the blocks configured with <varname>CopyBlocks=</varname>
564 are copied in or the file system configured with <varname>Format=</varname> is created.</para>
565
cf1e172d 566 <para>The LUKS2 UUID is automatically derived from the partition UUID in a stable fashion. If
be0d27ee
ZJS
567 <literal>key-file</literal> or <literal>key-file+tpm2</literal> is used, a key is added to the LUKS2
568 superblock, configurable with the <option>--key-file=</option> option to
cf1e172d 569 <command>systemd-repart</command>. If <literal>tpm2</literal> or <literal>key-file+tpm2</literal> is
be0d27ee 570 used, a key is added to the LUKS2 superblock that is enrolled to the local TPM2 chip, as configured
cf1e172d 571 with the <option>--tpm2-device=</option> and <option>--tpm2-pcrs=</option> options to
dfb4d0ae
LP
572 <command>systemd-repart</command>.</para>
573
574 <para>When used this slightly alters the size allocation logic as the implicit, minimal size limits
575 of <varname>Format=</varname> and <varname>CopyBlocks=</varname> are increased by the space necessary
576 for the LUKS2 superblock (see above).</para>
577
578 <para>This option has no effect if the partition already exists.</para></listitem>
757bc2e4
LP
579 </varlistentry>
580
917cc808
LP
581 <varlistentry>
582 <term><varname>FactoryReset=</varname></term>
583
584 <listitem><para>Takes a boolean argument. If specified the partition is marked for removal during a
585 factory reset operation. This functionality is useful to implement schemes where images can be reset
586 into their original state by removing partitions and creating them anew. Defaults to off.</para></listitem>
587 </varlistentry>
e73309c5
LP
588
589 <varlistentry>
590 <term><varname>Flags=</varname></term>
591
ff0771bf 592 <listitem><para>Configures the 64bit GPT partition flags field to set for the partition when creating
e73309c5 593 it. This option has no effect if the partition already exists. If not specified the flags values is
ff0771bf
LP
594 set to all zeroes, except for the three bits that can also be configured via
595 <varname>NoAuto=</varname>, <varname>ReadOnly=</varname> and <varname>GrowFileSystem=</varname>; see
596 below for details on the defaults for these three flags. Specify the flags value in hexadecimal (by
597 prefixing it with <literal>0x</literal>), binary (prefix <literal>0b</literal>) or decimal (no
598 prefix).</para></listitem>
e73309c5
LP
599 </varlistentry>
600
601 <varlistentry>
ff0771bf 602 <term><varname>NoAuto=</varname></term>
e73309c5 603 <term><varname>ReadOnly=</varname></term>
1c41c1dc
LP
604 <term><varname>GrowFileSystem=</varname></term>
605
ff0771bf
LP
606 <listitem><para>Configures the No-Auto, Read-Only and Grow-File-System partition flags (bit 63, 60
607 and 59) of the partition table entry, as defined by the <ulink
1c41c1dc 608 url="https://systemd.io/DISCOVERABLE_PARTITIONS">Discoverable Partitions Specification</ulink>. Only
ff0771bf
LP
609 available for partition types supported by the specification. This option is a friendly way to set
610 bits 63, 60 and 59 of the partition flags value without setting any of the other bits, and may be set
611 via <varname>Flags=</varname> too, see above.</para>
1c41c1dc 612
ff0771bf
LP
613 <para>If <varname>Flags=</varname> is used in conjunction with one or more of
614 <varname>NoAuto=</varname>/<varname>ReadOnly=</varname>/<varname>GrowFileSystem=</varname> the latter
615 control the value of the relevant flags, i.e. the high-level settings
616 <varname>NoAuto=</varname>/<varname>ReadOnly=</varname>/<varname>GrowFileSystem=</varname> override
617 the relevant bits of the low-level setting <varname>Flags=</varname>.</para>
1c41c1dc 618
ff0771bf 619 <para>Note that the three flags affect only automatic partition mounting, as implemented by
1c41c1dc
LP
620 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
621 or the <option>--image=</option> option of various commands (such as
622 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>). It
623 has no effect on explicit mounts, such as those done via <citerefentry
624 project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> or
625 <citerefentry
be0d27ee 626 project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
1c41c1dc
LP
627
628 <para>If both bit 50 and 59 are set for a partition (i.e. the partition is marked both read-only and
629 marked for file system growing) the latter is typically without effect: the read-only flag takes
630 precedence in most tools reading these flags, and since growing the file system involves writing to
631 the partition it is consequently ignored.</para>
632
ff0771bf
LP
633 <para><varname>NoAuto=</varname> defaults to off. <varname>ReadOnly=</varname> defaults to on for
634 Verity partition types, and off for all others. <varname>GrowFileSystem=</varname> defaults to on for
635 all partition types that support it, except if the partition is marked read-only (and thus
636 effectively, defaults to off for Verity partitions).</para></listitem>
e73309c5 637 </varlistentry>
917cc808
LP
638 </variablelist>
639 </refsect1>
640
e031166e
LP
641 <refsect1>
642 <title>Specifiers</title>
643
b3e22322
LP
644 <para>Specifiers may be used in the <varname>Label=</varname>, <varname>CopyBlocks=</varname>,
645 <varname>CopyFiles=</varname>, <varname>MakeDirectories=</varname> settings. The following expansions are
646 understood:</para>
e031166e
LP
647 <table class='specifiers'>
648 <title>Specifiers available</title>
649 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
650 <colspec colname="spec" />
651 <colspec colname="mean" />
652 <colspec colname="detail" />
653 <thead>
654 <row>
655 <entry>Specifier</entry>
656 <entry>Meaning</entry>
657 <entry>Details</entry>
658 </row>
659 </thead>
660 <tbody>
661 <xi:include href="standard-specifiers.xml" xpointer="a"/>
9a515f0a 662 <xi:include href="standard-specifiers.xml" xpointer="A"/>
e031166e
LP
663 <xi:include href="standard-specifiers.xml" xpointer="b"/>
664 <xi:include href="standard-specifiers.xml" xpointer="B"/>
665 <xi:include href="standard-specifiers.xml" xpointer="H"/>
666 <xi:include href="standard-specifiers.xml" xpointer="l"/>
667 <xi:include href="standard-specifiers.xml" xpointer="m"/>
9a515f0a 668 <xi:include href="standard-specifiers.xml" xpointer="M"/>
e031166e
LP
669 <xi:include href="standard-specifiers.xml" xpointer="o"/>
670 <xi:include href="standard-specifiers.xml" xpointer="v"/>
671 <xi:include href="standard-specifiers.xml" xpointer="w"/>
672 <xi:include href="standard-specifiers.xml" xpointer="W"/>
b3e22322
LP
673 <xi:include href="standard-specifiers.xml" xpointer="T"/>
674 <xi:include href="standard-specifiers.xml" xpointer="V"/>
e031166e
LP
675 <xi:include href="standard-specifiers.xml" xpointer="percent"/>
676 </tbody>
677 </tgroup>
678 </table>
679 </refsect1>
680
917cc808
LP
681 <refsect1>
682 <title>Examples</title>
683
684 <example>
685 <title>Grow the root partition to the full disk size at first boot</title>
686
687 <para>With the following file the root partition is automatically grown to the full disk if possible during boot.</para>
688
689 <para><programlisting># /usr/lib/repart.d/50-root.conf
690[Partition]
691Type=root
692</programlisting></para>
693 </example>
694
695 <example>
696 <title>Create a swap and home partition automatically on boot, if missing</title>
697
698 <para>The home partition gets all available disk space while the swap partition gets 1G at most and 64M
699 at least. We set a priority > 0 on the swap partition to ensure the swap partition is not used if not
700 enough space is available. For every three bytes assigned to the home partition the swap partition gets
701 assigned one.</para>
702
703 <para><programlisting># /usr/lib/repart.d/60-home.conf
704[Partition]
705Type=home
706</programlisting></para>
707
708 <para><programlisting># /usr/lib/repart.d/70-swap.conf
709[Partition]
710Type=swap
711SizeMinBytes=64M
712SizeMaxBytes=1G
713Priority=1
714Weight=333
715</programlisting></para>
716 </example>
717
718 <example>
719 <title>Create B partitions in an A/B Verity setup, if missing</title>
720
721 <para>Let's say the vendor intends to update OS images in an A/B setup, i.e. with two root partitions
722 (and two matching Verity partitions) that shall be used alternatingly during upgrades. To minimize
723 image sizes the original image is shipped only with one root and one Verity partition (the "A" set),
724 and the second root and Verity partitions (the "B" set) shall be created on first boot on the free
725 space on the medium.</para>
726
727 <para><programlisting># /usr/lib/repart.d/50-root.conf
728[Partition]
729Type=root
730SizeMinBytes=512M
731SizeMaxBytes=512M
732</programlisting></para>
733
734 <para><programlisting># /usr/lib/repart.d/60-root-verity.conf
735[Partition]
736Type=root-verity
737SizeMinBytes=64M
738SizeMaxBytes=64M
739</programlisting></para>
740
741 <para>The definitions above cover the "A" set of root partition (of a fixed 512M size) and Verity
742 partition for the root partition (of a fixed 64M size). Let's use symlinks to create the "B" set of
743 partitions, since after all they shall have the same properties and sizes as the "A" set.</para>
744
745<para><programlisting># ln -s 50-root.conf /usr/lib/repart.d/70-root-b.conf
746# ln -s 60-root-verity.conf /usr/lib/repart.d/80-root-verity-b.conf
747</programlisting></para>
748 </example>
749
750 </refsect1>
751
752 <refsect1>
753 <title>See Also</title>
754 <para>
755 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
756 <citerefentry><refentrytitle>systemd-repart</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
cf1e172d
LP
757 <citerefentry project='man-pages'><refentrytitle>sfdisk</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
758 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
917cc808
LP
759 </para>
760 </refsect1>
761
762</refentry>