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