Debian Codegraph @

man/systemd-repart.xml

raw
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd-repart" conditional='ENABLE_REPART'
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>systemd-repart</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>systemd-repart</refentrytitle>
16 <manvolnum>8</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>systemd-repart</refname>
21 <refname>systemd-repart.service</refname>
22 <refpurpose>Automatically grow and add partitions, and generate disk images (DDIs)</refpurpose>
23 </refnamediv>
24
25 <refsynopsisdiv>
26 <cmdsynopsis>
27 <command>systemd-repart</command>
28 <arg choice="opt" rep="repeat">OPTIONS</arg>
29 <arg choice="opt">BLOCKDEVICE</arg>
30 </cmdsynopsis>
31
32 <para><filename>systemd-repart.service</filename></para>
33 </refsynopsisdiv>
34
35 <refsect1>
36 <title>Description</title>
37
38 <para><command>systemd-repart</command> creates partition tables, and adds or grows partitions, based on
39 the configuration files described in
40 <citerefentry><refentrytitle>repart.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. It operates
41 on the block device or file image specified on the command line.</para>
42
43 <para><command>systemd-repart</command> is used when <emphasis>building</emphasis> OS images, and also
44 when <emphasis>deploying</emphasis> images to automatically adjust them, during boot, to the system they
45 are running on. This way the image can be minimal in size and may be augmented automatically at boot,
46 taking possession of the disk space available.</para>
47
48 <para>If invoked with no arguments, <command>systemd-repart</command> operates on the block device
49 backing the root file system partition of the running OS, thus adding and growing partitions of the
50 booted OS itself. When called in the initrd, it operates on the block device backing
51 <filename>/sysroot/</filename> instead, i.e. on the block device the system will soon transition into. If
52 <varname>--image=</varname> is used, it will operate on the specified device or image file. The
53 <filename>systemd-repart.service</filename> service is generally run at boot in the initrd, in order to
54 augment the partition table of the OS before its partitions are mounted.</para>
55
56 <para>If the block device is specified as <literal>-</literal> (or as an empty string),
57 <command>systemd-repart</command> will not operate on any block device or image file, and instead
58 determine and output the minimum disk/image size for the specified partition configuration, taking all
59 configured size constraints into account.</para>
60
61 <para><command>systemd-repart</command> operations are mostly incremental: it grows existing partitions
62 or adds new ones, but does not shrink, delete, or move existing partitions. The service is intended to be
63 run on every boot, but when it detects that the partition table already matches the installed
64 <filename>repart.d/*.conf</filename> configuration files, it executes no operation.</para>
65
66 <para>The following use cases are among those covered:</para>
67
68 <itemizedlist>
69 <listitem><para>The root partition may be grown to cover the whole available disk space.</para></listitem>
70 <listitem><para>A <filename>/home/</filename>, swap, or <filename>/srv/</filename> partition can be
71 added.</para></listitem>
72 <listitem><para>A second (or third, …) root partition may be added, to cover A/B style setups
73 where a second version of the root file system is alternatingly used for implementing update
74 schemes. The deployed image would carry only a single partition ("A") but on first boot a second
75 partition ("B") for this purpose is automatically created.</para></listitem>
76 </itemizedlist>
77
78 <para>The algorithm executed by <command>systemd-repart</command> is roughly as follows:</para>
79
80 <orderedlist>
81 <listitem><para>The <filename>repart.d/*.conf</filename> configuration files are loaded and parsed, and
82 ordered by filename (without the directory prefix). For each configuration file, drop-in files are
83 loaded from directories with same name as the configuration file with the suffix ".d" added.
84 </para></listitem>
85
86 <listitem><para>The partition table on the block device is loaded and parsed, if present.
87 </para></listitem>
88
89 <listitem><para>The existing partitions in the partition table are matched with the
90 <filename>repart.d/*.conf</filename> files by GPT partition type UUID. The first existing partition of
91 a specific type is assigned the first configuration file declaring the same type. The second existing
92 partition of a specific type is then assigned the second configuration file declaring the same type,
93 and so on. After this iterative assigning is complete, any existing partitions that have no matching
94 configuration file are considered "foreign" and left as they are. And any configuration files for which
95 no partition was matched are treated as requests to create a partition.</para></listitem>
96
97 <listitem><para>Partitions that shall be created are now allocated on the disk, taking the size
98 constraints and weights declared in the configuration files into account. Free space is used within the
99 limits set by size and padding requests. In addition, existing partitions that should be grown are
100 grown. New partitions are always appended to the end of the partition table, taking the first partition
101 table slot whose index is greater than the indexes of all existing partitions. Partitions are never
102 reordered and thus partition numbers remain stable. When partitions are created, they are placed in the
103 smallest area of free space that is large enough to satisfy the size and padding limits. This means
104 that partitions might have different order on disk than in the partition table. Note that this
105 allocation happens in memory only, the partition table on disk is not updated yet.</para></listitem>
106
107 <listitem><para>All existing partitions for which configuration files exist and which currently have no
108 GPT partition label set will be assigned a label, either explicitly configured in the configuration or
109 — if that's missing — derived automatically from the partition type. The same is done for all
110 partitions that are newly created. These assignments are done in memory only, too, the disk is not
111 updated yet.</para></listitem>
112
113 <listitem><para>Similarly, all existing partitions for which configuration files exist and which
114 currently have an all-zero identifying UUID will be assigned a new UUID. This UUID is cryptographically
115 hashed from a common seed value together with the partition type UUID (and a counter in case multiple
116 partitions of the same type are defined), see below. The same is done for all partitions that are
117 created anew. These assignments are done in memory only, too, the disk is not updated yet.
118 </para></listitem>
119
120 <listitem><para>Similarly, if the disk's volume UUID is all zeroes it is also initialized, also
121 cryptographically hashed from the same common seed value. This is done in memory only too.
122 </para></listitem>
123
124 <listitem><para>The disk space assigned to new partitions (i.e. what was previously free space) is now
125 erased. Specifically, all file system signatures are removed, and if the device supports it, the
126 <constant>BLKDISCARD</constant> I/O control command is issued to inform the hardware that the space is
127 now empty. In addition any "padding" between partitions and at the end of the device is similarly
128 erased.</para></listitem>
129
130 <listitem><para>The new partition table is finally written to disk. The kernel is asked to reread the
131 partition table.</para></listitem>
132 </orderedlist>
133
134 <para>As an exception to the normal incremental operation, when called in a special "factory reset" mode,
135 <command>systemd-repart</command> may be used to erase existing partitions to reset an installation back
136 to vendor defaults. This mode of operation is used when either the <option>--factory-reset=yes</option>
137 switch is passed on the tool's command line, or the <option>systemd.factory_reset=yes</option> option is
138 specified on the kernel command line, or the <varname>FactoryResetRequest</varname> EFI variable (vendor
139 UUID <constant>8cf2644b-4b0b-428f-9387-6d876050dc67</constant>) is set to "yes". It alters the algorithm
140 above slightly: between the 3rd and the 4th step above any partition marked explicitly via the
141 <varname>FactoryReset=</varname> boolean is deleted, and the algorithm restarted, thus immediately
142 re-creating these partitions anew empty.</para>
143
144 <para>Note that <command>systemd-repart</command> by default only changes partition tables, it does not
145 create or resize any file systems within these partitions, unless the <varname>Format=</varname>
146 configuration option is specified. Also note that there are also separate mechanisms available for this
147 purpose, for example
148 <citerefentry><refentrytitle>systemd-growfs</refentrytitle><manvolnum>8</manvolnum></citerefentry> and
149 <command>systemd-makefs</command>.</para>
150
151 <para>The UUIDs identifying the new partitions created (or assigned to existing partitions that have no
152 UUID yet), as well as the disk as a whole are hashed cryptographically from a common seed value. This
153 seed value is usually the
154 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> of the
155 system, so that the machine ID reproducibly determines the UUIDs assigned to all partitions. If the
156 machine ID cannot be read (or the user passes <option>--seed=random</option>, see below) the seed is
157 generated randomly instead, so that the partition UUIDs are also effectively random. The seed value may
158 also be set explicitly, formatted as UUID via the <option>--seed=</option> option. By hashing these UUIDs
159 from a common seed images prepared with this tool become reproducible and the result of the algorithm
160 above deterministic.</para>
161
162 <para>The positional argument should specify the block device or a regular file to operate on. If
163 <option>--empty=create</option> is specified, the specified path is created as regular file, which is
164 useful for generating disk images from scratch.</para>
165 </refsect1>
166
167 <refsect1>
168 <title>Options</title>
169
170 <para>The following options are understood:</para>
171
172 <variablelist>
173 <varlistentry>
174 <term><option>--dry-run=</option></term>
175
176 <listitem><para>Takes a boolean. If this switch is not specified, <option>--dry-run=yes</option> is
177 the implied default. Controls whether <filename>systemd-repart</filename> executes the requested
178 re-partition operations or whether it should only show what it would do. Unless
179 <option>--dry-run=no</option> is specified <filename>systemd-repart</filename> will not actually
180 touch the device's partition table.</para>
181
182 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
183 </varlistentry>
184
185 <varlistentry>
186 <term><option>--empty=</option></term>
187
188 <listitem><para>Takes one of <literal>refuse</literal>, <literal>allow</literal>,
189 <literal>require</literal>, <literal>force</literal> or <literal>create</literal>. Controls how to
190 operate on block devices that are entirely empty, i.e. carry no partition table/disk label yet. If
191 this switch is not specified, the implied default is <literal>refuse</literal>.</para>
192
193 <para>If <literal>refuse</literal> <command>systemd-repart</command> requires that the block device
194 it shall operate on already carries a partition table and refuses operation if none is found. If
195 <literal>allow</literal> the command will extend an existing partition table or create a new one if
196 none exists. If <literal>require</literal> the command will create a new partition table if none
197 exists so far, and refuse operation if one already exists. If <literal>force</literal> it will create
198 a fresh partition table unconditionally, erasing the disk fully in effect. If
199 <literal>force</literal> no existing partitions will be taken into account or survive the
200 operation. Hence: use with care, this is a great way to lose all your data. If
201 <literal>create</literal> a new loopback file is create under the path passed via the device node
202 parameter, of the size indicated with <option>--size=</option>, see below.</para>
203
204 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
205 </varlistentry>
206
207 <varlistentry>
208 <term><option>--discard=</option></term>
209
210 <listitem><para>Takes a boolean. If this switch is not specified ,<option>--discard=yes</option> is
211 the implied default. Controls whether to issue the <constant>BLKDISCARD</constant> I/O control
212 command on the space taken up by any added partitions or on the space in between them. Usually, it is
213 a good idea to issue this request since it tells the underlying hardware that the covered blocks
214 shall be considered empty, improving performance. If operating on a regular file instead of a block
215 device node, a sparse file is generated.</para>
216
217 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
218 </varlistentry>
219
220 <varlistentry>
221 <term><option>--size=</option></term>
222
223 <listitem><para>Takes a size in bytes, using the usual K, M, G, T suffixes, or the special value
224 <literal>auto</literal>. If used the specified device node path must refer to a regular file, which
225 is then grown to the specified size if smaller, before any change is made to the partition table. If
226 specified as <literal>auto</literal> the minimal size for the disk image is automatically determined
227 (i.e. the minimal sizes of all partitions are summed up, taking space for additional metadata into
228 account). This switch is not supported if the specified node is a block device. This switch has no
229 effect if the file is already as large as the specified size or larger. The specified size is
230 implicitly rounded up to multiples of 4096. When used with <option>--empty=create</option> this
231 specifies the initial size of the loopback file to create.</para>
232
233 <para>The <option>--size=auto</option> option takes the sizes of pre-existing partitions into
234 account. However, it does not accommodate for partition tables that are not tightly packed: the
235 configured partitions might still not fit into the backing device if empty space exists between
236 pre-existing partitions (or before the first partition) that cannot be fully filled by partitions to
237 grow or create.</para>
238
239 <para>Also note that the automatic size determination does not take files or directories specified
240 with <option>CopyFiles=</option> into account: operation might fail if the specified files or
241 directories require more disk space then the configured per-partition minimal size
242 limit.</para>
243
244 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
245 </varlistentry>
246
247 <varlistentry>
248 <term><option>--factory-reset=</option></term>
249
250 <listitem><para>Takes boolean. If this switch is not specified, <option>--factory-reset=no</option> is
251 the implied default. Controls whether to operate in "factory reset" mode, see above. If set to true
252 this will remove all existing partitions marked with <varname>FactoryReset=</varname> set to yes
253 early while executing the re-partitioning algorithm. Use with care, this is a great way to lose all
254 your data. Note that partition files need to explicitly turn <varname>FactoryReset=</varname> on, as
255 the option defaults to off. If no partitions are marked for factory reset this switch has no
256 effect. Note that there are two other methods to request factory reset operation: via the kernel
257 command line and via an EFI variable, see above.</para>
258
259 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
260 </varlistentry>
261
262 <varlistentry>
263 <term><option>--can-factory-reset</option></term>
264
265 <listitem><para>If this switch is specified the disk is not re-partitioned. Instead it is determined
266 if any existing partitions are marked with <varname>FactoryReset=</varname>. If there are the tool
267 will exit with exit status zero, otherwise non-zero. This switch may be used to quickly determine
268 whether the running system supports a factory reset mechanism built on
269 <command>systemd-repart</command>.</para>
270
271 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
272 </varlistentry>
273
274 <varlistentry>
275 <term><option>--root=</option></term>
276
277 <listitem><para>Takes a path to a directory to use as root file system when searching for
278 <filename>repart.d/*.conf</filename> files, for the machine ID file to use as seed and for the
279 <varname>CopyFiles=</varname> and <varname>CopyBlocks=</varname> source files and directories. By
280 default when invoked on the regular system this defaults to the host's root file system
281 <filename>/</filename>. If invoked from the initrd this defaults to <filename>/sysroot/</filename>,
282 so that the tool operates on the configuration and machine ID stored in the root file system later
283 transitioned into itself.</para>
284
285 <para>See <option>--copy-source=</option> for a more restricted option that only affects
286 <varname>CopyFiles=</varname>.</para>
287
288 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
289 </varlistentry>
290
291 <varlistentry>
292 <term><option>--image=</option></term>
293
294 <listitem><para>Takes a path to a disk image file or device to mount and use in a similar fashion to
295 <option>--root=</option>, see above.</para>
296
297 <xi:include href="version-info.xml" xpointer="v249"/></listitem>
298 </varlistentry>
299
300 <xi:include href="standard-options.xml" xpointer="image-policy-open" />
301
302 <varlistentry>
303 <term><option>--seed=</option></term>
304
305 <listitem><para>Takes a UUID as argument or the special value <constant>random</constant>. If a UUID
306 is specified the UUIDs to assign to partitions and the partition table itself are derived via
307 cryptographic hashing from it. If not specified, it is attempted to read the machine ID from the host
308 (or more precisely, the root directory configured via <option>--root=</option>) and use it as seed
309 instead, falling back to a randomized seed otherwise. Use <option>--seed=random</option> to force a
310 randomized seed. Explicitly specifying the seed may be used to generated strictly reproducible
311 partition tables.</para>
312
313 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
314 </varlistentry>
315
316 <varlistentry>
317 <term><option>--pretty=</option></term>
318
319 <listitem><para>Takes a boolean argument. If this switch is not specified, it defaults to on when
320 called from an interactive terminal and off otherwise. Controls whether to show a user friendly table
321 and graphic illustrating the changes applied.</para>
322
323 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
324 </varlistentry>
325
326 <varlistentry>
327 <term><option>--definitions=</option></term>
328
329 <listitem><para>Takes a file system path. If specified the <filename>*.conf</filename> files are read
330 from the specified directory instead of searching in <filename>/usr/lib/repart.d/*.conf</filename>,
331 <filename>/etc/repart.d/*.conf</filename>,
332 <filename>/run/repart.d/*.conf</filename>.</para>
333
334 <para>This parameter can be specified multiple times.</para>
335
336 <xi:include href="version-info.xml" xpointer="v245"/></listitem>
337 </varlistentry>
338
339 <varlistentry>
340 <term><option>--key-file=</option></term>
341
342 <listitem><para>Takes a file system path. Configures the encryption key to use when setting up LUKS2
343 volumes configured with the <varname>Encrypt=key-file</varname> setting in partition files. Should
344 refer to a regular file containing the key, or an <constant>AF_UNIX</constant> stream socket in the
345 file system. In the latter case, a connection is made to it and the key read from it. If this switch
346 is not specified, and no <varname>KeyFile=</varname> is specified in the partition file, the empty
347 key (i.e. zero length key) is used. This behaviour is useful for setting up encrypted partitions during
348 early first boot that receive their user-supplied password only in a later setup step.</para>
349
350 <xi:include href="version-info.xml" xpointer="v247"/></listitem>
351 </varlistentry>
352
353 <varlistentry>
354 <term><option>--private-key=</option></term>
355
356 <listitem><para>Takes a file system path or an engine or provider specific designation. Configures
357 the signing key to use when creating verity signature partitions with the
358 <varname>Verity=signature</varname> setting in partition files.</para>
359
360 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
361 </varlistentry>
362
363 <varlistentry>
364 <term><option>--private-key-source=</option></term>
365
366 <listitem><para>Takes one of <literal>file</literal>, <literal>engine</literal> or
367 <literal>provider</literal>. In the latter two cases, it is followed by the name of a provider or
368 engine, separated by colon, that will be passed to OpenSSL's "engine" or "provider" logic.
369 Configures how to load the private key to use when creating verity signature partitions with the
370 <varname>Verity=signature</varname> setting in partition files.</para>
371
372 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
373 </varlistentry>
374
375 <varlistentry>
376 <term><option>--certificate=</option></term>
377
378 <listitem><para>Takes a file system path or a provider specific designation. Configures the PEM
379 encoded X.509 certificate to use when creating verity signature partitions with the
380 <varname>Verity=signature</varname> setting in partition files.</para>
381
382 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
383 </varlistentry>
384
385 <varlistentry>
386 <term><option>--certificate-source=</option></term>
387
388 <listitem><para>Takes one of <literal>file</literal>, or <literal>provider</literal>. In the latter
389 case, it is followed by the name of a provider, separated by colon, that will be passed to OpenSSL's
390 "provider" logic. Configures how to load the X.509 certificate to use when creating verity signature
391 partitions with the <varname>Verity=signature</varname> setting in partition files.</para>
392
393 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
394 </varlistentry>
395
396 <varlistentry>
397 <term><option>--join-signature=</option></term>
398
399 <listitem><para>Specifies a colon-separated tuple with a hex-encoded top-level Verity hash of a
400 <varname>Verity=hash</varname> partition as first element, and a PKCS7 signature of the roothash
401 as a path to a DER-encoded signature file, or as an ASCII base64 string encoding of a DER-encoded
402 signature prefixed by <literal>base64:</literal>. To be used on a pre-existing image that was
403 created with a parameter such as <option>--defer-partitions=root-verity-sig</option>, in order to
404 allow implementing offline signing of the verity signature partition.</para>
405
406 <para>This is an alternative to online signing using parameters such as
407 <option>--private-key=</option>, for build systems where the private key for production signing is
408 not available in the same context where content is created.</para>
409
410 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
411 </varlistentry>
412
413 <varlistentry>
414 <term><option>--tpm2-device=</option></term>
415 <term><option>--tpm2-pcrs=</option></term>
416
417 <listitem><para>Configures the TPM2 device and list of PCRs to use for LUKS2 volumes configured with
418 the <varname>Encrypt=tpm2</varname> option. These options take the same parameters as the identically
419 named options to
420 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
421 and have the same effect on partitions where TPM2 enrollment is requested.</para>
422
423 <xi:include href="version-info.xml" xpointer="v248"/></listitem>
424 </varlistentry>
425
426 <varlistentry>
427 <term><option>--tpm2-device-key=<replaceable>PATH</replaceable></option></term>
428 <term><option>--tpm2-seal-key-handle=<replaceable>HANDLE</replaceable></option></term>
429
430 <listitem><para>Configures a TPM2 SRK key to bind encryption to. See
431 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
432 for details on this option.</para>
433
434 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
435 </varlistentry>
436
437 <varlistentry>
438 <term><option>--tpm2-public-key=<replaceable>PATH</replaceable></option></term>
439 <term><option>--tpm2-public-key-pcrs=<replaceable>PCR<optional>+PCR...</optional></replaceable></option></term>
440
441 <listitem><para>Configures a TPM2 signed PCR policy to bind encryption to. See
442 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
443 for details on these two options.</para>
444
445 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
446 </varlistentry>
447
448 <varlistentry>
449 <term><option>--tpm2-pcrlock=<replaceable>PATH</replaceable></option></term>
450
451 <listitem><para>Configures a TPM2 pcrlock policy to bind encryption to. See
452 <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
453 for details on this option.</para>
454
455 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
456 </varlistentry>
457
458 <varlistentry>
459 <term><option>--split=<replaceable>BOOL</replaceable></option></term>
460
461 <listitem><para>Enables generation of split artifacts from partitions configured with
462 <varname>SplitName=</varname>. If enabled, for each partition with <varname>SplitName=</varname> set,
463 a separate output file containing just the contents of that partition is generated. The output
464 filename consists of the loopback filename suffixed with the name configured with
465 <varname>SplitName=</varname>. If the loopback filename ends with <literal>.raw</literal>, the suffix
466 is inserted before the <literal>.raw</literal> extension instead.</para>
467
468 <para>Note that <option>--split</option> is independent from <option>--dry-run</option>. Even if
469 <option>--dry-run</option> is enabled, split artifacts will still be generated from an existing image
470 if <option>--split</option> is enabled.</para>
471
472 <xi:include href="version-info.xml" xpointer="v252"/></listitem>
473 </varlistentry>
474
475 <varlistentry>
476 <term><option>--include-partitions=<replaceable>PARTITIONS</replaceable></option></term>
477 <term><option>--exclude-partitions=<replaceable>PARTITIONS</replaceable></option></term>
478
479 <listitem><para>These options specify which partition types <command>systemd-repart</command> should
480 operate on. If <option>--include-partitions=</option> is used, all partitions that are not specified
481 are excluded. If <option>--exclude-partitions=</option> is used, all partitions that are specified
482 are excluded. Both options take a comma separated list of GPT partition type UUIDs or identifiers
483 (see <varname>Type=</varname> in
484 <citerefentry><refentrytitle>repart.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
485 </para>
486
487 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
488 </varlistentry>
489
490 <varlistentry>
491 <term><option>--defer-partitions=<replaceable>PARTITIONS</replaceable></option></term>
492
493 <listitem><para>This option specifies for which partition types <command>systemd-repart</command>
494 should defer. All partitions that are deferred using this option are still taken into account when
495 calculating the sizes and offsets of other partitions, but are not actually written to the disk image.
496 The net effect of this option is that if you run <command>systemd-repart</command> again without this
497 option, the missing partitions will be added as if they had not been deferred the first time
498 <command>systemd-repart</command> was executed.</para>
499
500 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
501 </varlistentry>
502
503 <varlistentry>
504 <term><option>--defer-partitions-empty=yes</option></term>
505
506 <listitem><para>This is very similar to <option>--defer-partitions=</option> but automatically
507 selects all partitions for deferral that have <option>Format=empty</option> set and do not configure
508 a custom label, or which set <option>Label=_empty</option>. It may be used in conjunction with
509 <option>--defer-partitions=</option> or <option>--defer-partitions-factory-reset=yes</option>, in
510 which case all matching partitions are deferred.</para>
511
512 <xi:include href="version-info.xml" xpointer="v259"/></listitem>
513 </varlistentry>
514
515 <varlistentry>
516 <term><option>--defer-partitions-factory-reset=yes</option></term>
517
518 <listitem><para>This is very similar to <option>--defer-partitions=</option> but automatically
519 selects all partitions for deferral that have <option>FactoryReset=yes</option> set. It may be used
520 in conjunction with <option>--defer-partitions=</option> or
521 <option>--defer-partitions-empty=yes</option>, in which case all matching partitions are
522 deferred.</para>
523
524 <xi:include href="version-info.xml" xpointer="v259"/></listitem>
525 </varlistentry>
526
527 <varlistentry>
528 <term><option>--sector-size=<replaceable>BYTES</replaceable></option></term>
529
530 <listitem><para>This option allows configuring the sector size of the image produced by
531 <command>systemd-repart</command>. It takes a value that is a power of <literal>2</literal> between
532 <literal>512</literal> and <literal>4096</literal>. This option is useful when building images for
533 disks that use a different sector size as the disk on which the image is produced.</para>
534
535 <xi:include href="version-info.xml" xpointer="v253"/></listitem>
536 </varlistentry>
537
538 <varlistentry>
539 <term><option>--grain-size=<replaceable>BYTES</replaceable></option></term>
540
541 <listitem><para>This option controls the partition alignment granularity used when placing
542 partitions. It takes a power-of-2 value that is at least the sector size. All partition start
543 offsets will be rounded up to a multiple of this value. Defaults to
544 <constant>MAX(4096, sector_size)</constant>, matching the conventional 4 KiB alignment. Setting
545 this to <literal>1M</literal> ensures proper alignment for modern storage devices even after
546 small fixed-size partitions such as a verity signature partition.</para>
547
548 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
549 </varlistentry>
550
551 <varlistentry>
552 <term><option>--architecture=<replaceable>ARCH</replaceable></option></term>
553
554 <listitem><para>This option allows overriding the architecture used for architecture specific
555 partition types. For example, if set to <literal>arm64</literal> a partition type of
556 <literal>root-x86-64</literal> referenced in <filename>repart.d/</filename> drop-ins will be patched
557 dynamically to refer to <literal>root-arm64</literal> instead. Takes one of
558 <literal>alpha</literal>,
559 <literal>arc</literal>,
560 <literal>arm</literal>,
561 <literal>arm64</literal>,
562 <literal>ia64</literal>,
563 <literal>loongarch64</literal>,
564 <literal>mips-le</literal>,
565 <literal>mips64-le</literal>,
566 <literal>parisc</literal>,
567 <literal>ppc</literal>,
568 <literal>ppc64</literal>,
569 <literal>ppc64-le</literal>,
570 <literal>riscv32</literal>,
571 <literal>riscv64</literal>,
572 <literal>s390</literal>,
573 <literal>s390x</literal>,
574 <literal>tilegx</literal>,
575 <literal>x86</literal> or
576 <literal>x86-64</literal>.</para>
577
578 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
579 </varlistentry>
580
581 <varlistentry>
582 <term><option>--offline=<replaceable>BOOL</replaceable></option></term>
583
584 <listitem><para>Instructs <command>systemd-repart</command> to build the image offline. Takes a
585 boolean or <literal>auto</literal>. Defaults to <literal>auto</literal>. If enabled, the image is
586 built without using loop devices. This is useful to build images unprivileged or when loop devices
587 are not available. If disabled, the image is always built using loop devices. If
588 <literal>auto</literal>, <command>systemd-repart</command> will build the image online if possible
589 and fall back to building the image offline if loop devices are not available or cannot be accessed
590 due to missing permissions.</para>
591
592 <xi:include href="version-info.xml" xpointer="v254"/></listitem>
593 </varlistentry>
594
595 <varlistentry>
596 <term><option>--copy-from=<replaceable>PATH</replaceable></option></term>
597
598 <listitem><para>Instructs <command>systemd-repart</command> to synthesize partition definitions from
599 the partition table in the given image or device. This option can be specified multiple times to
600 synthesize definitions from each of the given images or devices. The generated definitions will copy
601 the partitions into the destination partition table. The copied partitions will have the same size,
602 metadata and contents but might have a different partition number and might be located at a different
603 offset in the destination partition table. These definitions can be combined with partition
604 definitions read from regular partition definition files. The synthesized definitions take precedence
605 over the definitions read from partition definition files.</para>
606
607 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
608 </varlistentry>
609
610 <varlistentry>
611 <term><option>--copy-source=<replaceable>PATH</replaceable></option></term>
612 <term><option>-s</option> <replaceable>PATH</replaceable></term>
613
614 <listitem><para>Specifies a source directory all <varname>CopyFiles=</varname> source paths shall be
615 considered relative to. This is similar to <option>--root=</option>, but exclusively applies to the
616 <varname>CopyFiles=</varname> setting. If <option>--root=</option> and
617 <option>--copy-source=</option> are used in combination the former applies as usual, except for
618 <varname>CopyFiles=</varname> where the latter takes precedence.</para>
619
620 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
621 </varlistentry>
622
623 <varlistentry>
624 <term><option>--make-ddi=<replaceable>TYPE</replaceable></option></term>
625
626 <listitem><para>Takes one of <literal>sysext</literal>, <literal>confext</literal> or
627 <literal>portable</literal>. Generates a Discoverable Disk Image (DDI) for a system extension
628 (sysext, see
629 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry>
630 for details), configuration extension (confext) or <ulink
631 url="https://systemd.io/PORTABLE_SERVICES">Portable Services</ulink>. The generated image will consist
632 of a signed Verity <literal>erofs</literal> file system as root partition. In this mode of operation
633 the partition definitions in <filename>/usr/lib/repart.d/*.conf</filename> and related directories
634 are not read, and <option>--definitions=</option> is not supported, as appropriate definitions for
635 the selected DDI class will be chosen automatically.</para>
636
637 <para>Must be used in conjunction with <option>--copy-source=</option> to specify the file hierarchy
638 to populate the DDI with. The specified directory should contain an <filename>etc/</filename>
639 subdirectory if <literal>confext</literal> is selected. If <literal>sysext</literal> is selected it
640 should contain either a <filename>usr/</filename> or <filename>opt/</filename> directory, or both. If
641 <literal>portable</literal> is used a full OS file hierarchy can be provided.</para>
642
643 <para>This option implies <option>--empty=create</option>, <option>--size=auto</option> and
644 <option>--seed=random</option> (the latter two can be overridden).</para>
645
646 <para>The private key and certificate for signing the DDI must be specified via the
647 <option>--private-key=</option> and <option>--certificate=</option> switches.</para>
648
649 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
650 </varlistentry>
651
652 <varlistentry>
653 <term><option>-S</option></term>
654 <term><option>-C</option></term>
655 <term><option>-P</option></term>
656
657 <listitem><para>Shortcuts for <option>--make-ddi=sysext</option>,
658 <option>--make-ddi=confext</option>, <option>--make-ddi=portable</option>,
659 respectively.</para>
660
661 <xi:include href="version-info.xml" xpointer="v255"/></listitem>
662 </varlistentry>
663
664 <varlistentry>
665 <term><option>--append-fstab=</option></term>
666
667 <listitem><para>Takes one of <literal>no</literal>, <literal>auto</literal> or
668 <literal>replace</literal>. Controls how the generated
669 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
670 file by <option>--generate-fstab=</option> will behave in case that there is a previously
671 existing file.</para>
672
673 <para>If <literal>no</literal> <command>systemd-repart</command> will complain and abort in
674 case that there is a file. This is the default behaviour. If <literal>replace</literal>
675 the file will be silently replaced with the new generated one.</para>
676
677 <para>If <literal>auto</literal> <command>systemd-repart</command> will search in the pre-existing file
678 the section that belong to the automatically generated content and will replace it with the newer
679 generated content, and keep the user provided section if there is one. The generated section is
680 identified looking for the automatic content surrounded by
681 <literal># Start section ↓ of automatically generated fstab by systemd-repart</literal> and
682 <literal># End section ↑ of automatically generated fstab by systemd-repart</literal>. The content
683 that is before and after those comments are considered user provided, and kept in the new file.</para>
684
685 <xi:include href="version-info.xml" xpointer="v258"/></listitem>
686 </varlistentry>
687
688 <varlistentry>
689 <term><option>--generate-fstab=<replaceable>PATH</replaceable></option></term>
690
691 <listitem><para>Specifies a path where to write
692 <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>
693 entries for the mountpoints configured with <option>MountPoint=</option> in the root directory
694 specified with <option>--copy-source=</option> or <option>--root=</option> or in the host's root
695 directory if neither is specified. Disabled by default.</para>
696
697 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
698 </varlistentry>
699
700 <varlistentry>
701 <term><option>--generate-crypttab=<replaceable>PATH</replaceable></option></term>
702
703 <listitem><para>Specifies a path where to write crypttab entries for the encrypted volumes configured
704 with <option>EncryptedVolume=</option> in the root directory specified with
705 <option>--copy-source=</option> or <option>--root=</option> or in the host's root directory if
706 neither is specified. Disabled by default.</para>
707
708 <xi:include href="version-info.xml" xpointer="v256"/></listitem>
709 </varlistentry>
710
711 <varlistentry>
712 <term><option>--list-devices</option></term>
713
714 <listitem><para>Show a list of candidate block devices this command may operate on. Specifically,
715 this enumerates block devices currently present that support partition tables, and shows their device
716 node paths along with any of their symlinks.</para>
717
718 <xi:include href="version-info.xml" xpointer="v257"/></listitem>
719 </varlistentry>
720
721 <varlistentry>
722 <term><option>--el-torito=<replaceable>BOOL</replaceable></option></term>
723
724 <listitem><para>Write a minimal ISO9660 header with El Torito boot catalog. That will
725 boot the ESP on EFI firmware.</para>
726
727 <para>The ISO9660 filesystem created by it will be empty. The initramfs is expected to create a
728 partitionable loop device on top of the device to change the block size and enable GPT
729 partitions.</para>
730
731 <para>The disk requires at least one partition with <varname>Type=esp</varname>. The first one will
732 be the one referenced in the boot catalog.</para>
733
734 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
735 </varlistentry>
736
737 <varlistentry>
738 <term><option>--el-torito-system=<replaceable>STRING</replaceable></option></term>
739
740 <listitem><para>When creating an ISO9660 header, this value will be used as the system identifier.
741 This is useful for the media to be matched against osinfo db.</para>
742
743 <para>The value is limited to 32 characters.</para>
744
745 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
746 </varlistentry>
747
748 <varlistentry>
749 <term><option>--el-torito-volume=<replaceable>STRING</replaceable></option></term>
750
751 <listitem><para>When creating an ISO9660 header, this value will be used as volume identifier.
752 This is useful for the media to be matched against osinfo db.</para>
753
754 <para>The value is limited to 32 characters.</para>
755
756 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
757 </varlistentry>
758
759 <varlistentry>
760 <term><option>--el-torito-publisher=<replaceable>STRING</replaceable></option></term>
761
762 <listitem><para>When creating an ISO9660 header, this value will be used as publisher identifier.
763 This is useful for the media to be matched against osinfo db.</para>
764
765 <para>The value is limited to 128 characters.</para>
766
767 <xi:include href="version-info.xml" xpointer="v261"/></listitem>
768 </varlistentry>
769
770 <xi:include href="standard-options.xml" xpointer="help" />
771 <xi:include href="standard-options.xml" xpointer="version" />
772 <xi:include href="standard-options.xml" xpointer="no-pager" />
773 <xi:include href="standard-options.xml" xpointer="no-legend" />
774 <xi:include href="standard-options.xml" xpointer="json" />
775 </variablelist>
776 </refsect1>
777
778 <refsect1>
779 <title>Exit status</title>
780
781 <para>On success, 0 is returned, and a non-zero failure code otherwise.</para>
782 </refsect1>
783
784 <refsect1>
785 <title>Example</title>
786
787 <example>
788 <title>Generate a configuration extension image</title>
789
790 <para>The following creates a configuration extension DDI (confext) for an
791 <filename>/etc/motd</filename> update:</para>
792
793 <programlisting>mkdir -p tree/etc/extension-release.d
794 echo "Hello World" >tree/etc/motd
795 cat >tree/etc/extension-release.d/extension-release.my-motd &lt;&lt;EOF
796 ID=fedora
797 VERSION_ID=38
798 IMAGE_ID=my-motd
799 IMAGE_VERSION=7
800 EOF
801 systemd-repart -C \
802 --private-key=verity-private-key.pem \
803 --certificate=verity-certificate.pem \
804 -s tree/ \
805 /var/lib/confexts/my-motd.confext.raw
806 systemd-confext refresh</programlisting>
807
808 <para>The DDI generated that way may be applied to the system with
809 <citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
810 </example>
811
812 <example>
813 <title>Generate a system extension image and sign it via PKCS11</title>
814
815 <para>The following creates a system extension DDI (sysext) for an
816 <filename>/usr/foo</filename> update and signs it with a hardware token via PKCS11:</para>
817
818 <programlisting>mkdir -p tree/usr/lib/extension-release.d
819 echo "Hello World" >tree/usr/foo
820 cat >tree/usr/lib/extension-release.d/extension-release.my-foo &lt;&lt;EOF
821 ID=fedora
822 VERSION_ID=38
823 IMAGE_ID=my-foo
824 IMAGE_VERSION=7
825 EOF
826 systemd-repart --make-ddi=sysext \
827 --private-key-source=engine:pkcs11 \
828 --private-key="pkcs11:model=PKCS%2315%20emulated;manufacturer=piv_II;serial=0123456789abcdef;token=Some%20Cert" \
829 --certificate=verity-certificate.pem \
830 -s tree/ \
831 /var/lib/extensions/my-foo.sysext.raw
832 systemd-sysext refresh</programlisting>
833
834 <para>The DDI generated that way may be applied to the system with
835 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
836 </example>
837
838 <example>
839 <title>Generate a dm-verity signature offline and append it to a pre-built image</title>
840
841 <para>The following creates an image with dm-verity metadata, signs it separately to simulate an
842 offline signing system, and then appends the signature to the image:</para>
843
844 <programlisting>mkdir -p repart.d/ /tmp/tree/usr/lib/
845
846 cat >/tmp/tree/usr/lib/os-release &lt;&lt;EOF
847 ID=debian
848 VERSION_ID=13
849 EOF
850
851 cat >repart.d/10-root.conf &lt;&lt;EOF
852 [Partition]
853 Type=root
854 Format=erofs
855 SizeMinBytes=100M
856 SizeMaxBytes=100M
857 Verity=data
858 VerityMatchKey=root
859 EOF
860
861 cat >repart.d/11-root-verity.conf &lt;&lt;EOF
862 [Partition]
863 Type=root-verity
864 Label=%o_%w_verity
865 Verity=hash
866 VerityMatchKey=root
867 SizeMinBytes=400M
868 SizeMaxBytes=400M
869 EOF
870
871 cat >repart.d/12-root-verity-sig.conf &lt;&lt;EOF
872 [Partition]
873 Type=root-verity-sig
874 Label=%o_%w_verity_sig
875 Verity=signature
876 VerityMatchKey=root
877 EOF
878
879 systemd-repart --definitions repart.d \
880 --defer-partitions=root-verity-sig \
881 --copy-source=/tmp/tree/ \
882 --empty=create --size=600M \
883 --json=short \
884 /tmp/img.raw | jq --raw-output0 ".[-1].roothash" &gt; /tmp/img.roothash
885
886 openssl smime -sign -in /tmp/img.roothash \
887 -inkey verity-private-key.pem \
888 -signer verity-certificate.pem \
889 -noattr -binary -outform der \
890 -out /tmp/img.roothash.p7s
891
892 systemd-repart --definitions repart.d \
893 --dry-run=no --root=/tmp/tree/ \
894 --join-signature="$(cat /tmp/img.roothash):/tmp/img.roothash.p7s" \
895 --certificate=verity-certificate.pem \
896 /tmp/img.raw</programlisting>
897 </example>
898
899 </refsect1>
900
901 <refsect1>
902 <title>See Also</title>
903 <para><simplelist type="inline">
904 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
905 <member><citerefentry><refentrytitle>repart.d</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
906 <member><citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
907 <member><citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
908 <member><citerefentry><refentrytitle>portablectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
909 <member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
910 </simplelist></para>
911 </refsect1>
912
913 </refentry>