|
35 | 35 | <refsect1> |
36 | 36 | <title>Description</title> |
37 | 37 |
|
38 | | - <para><command>systemd-repart</command> grows and adds partitions to a partition table, based on the |
39 | | - configuration files described in |
| 38 | + <para><command>systemd-repart</command> creates partition tables, and adds or grows partitions, |
| 39 | + based on the configuration files described in |
40 | 40 | <citerefentry><refentrytitle>repart.d</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
41 | 41 | </para> |
42 | 42 |
|
43 | | - <para>If invoked with no arguments, it operates on the block device backing the root file system |
44 | | - partition of the running OS, thus growing and adding partitions of the booted OS image itself. If |
45 | | - <varname>--image=</varname> is used it will operate on the specified image file. When called in the |
46 | | - initrd it operates on the block device backing <filename>/sysroot/</filename> instead, i.e. on the block |
47 | | - device the system will soon transition into. The <filename>systemd-repart.service</filename> service is |
48 | | - generally run at boot in the initrd, in order to augment the partition table of the OS before its |
49 | | - partitions are mounted. <command>systemd-repart</command> (mostly) operates in a purely incremental mode: |
50 | | - it only grows existing and adds new partitions; it does not shrink, delete or move existing partitions. |
51 | | - The service is intended to be run on every boot, but when it detects that the partition table already |
52 | | - matches the installed <filename>repart.d/*.conf</filename> configuration files, it executes no |
53 | | - operation.</para> |
54 | | - |
55 | | - <para><command>systemd-repart</command> is intended to be used when deploying OS images, to automatically |
56 | | - adjust them to the system they are running on, during first boot. This way the deployed image can be |
57 | | - minimal in size and may be augmented automatically at boot when needed, taking possession of disk space |
58 | | - available but not yet used. Specifically the following use cases are among those covered:</para> |
| 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><command>systemd-repart</command> operations are mostly incremental: it grows existing partitions |
| 57 | + or adds new ones, but does not shrink, delete, or move existing partitions. The service is intended to be |
| 58 | + run on every boot, but when it detects that the partition table already matches the installed |
| 59 | + <filename>repart.d/*.conf</filename> configuration files, it executes no operation.</para> |
| 60 | + |
| 61 | + <para>The following use cases are among those covered:</para> |
59 | 62 |
|
60 | 63 | <itemizedlist> |
61 | 64 | <listitem><para>The root partition may be grown to cover the whole available disk space.</para></listitem> |
62 | | - <listitem><para>A <filename>/home/</filename>, swap or <filename>/srv/</filename> partition can be |
| 65 | + <listitem><para>A <filename>/home/</filename>, swap, or <filename>/srv/</filename> partition can be |
63 | 66 | added.</para></listitem> |
64 | 67 | <listitem><para>A second (or third, …) root partition may be added, to cover A/B style setups |
65 | 68 | where a second version of the root file system is alternatingly used for implementing update |
|
70 | 73 | <para>The algorithm executed by <command>systemd-repart</command> is roughly as follows:</para> |
71 | 74 |
|
72 | 75 | <orderedlist> |
73 | | - <listitem><para>The <filename>repart.d/*.conf</filename> configuration files are loaded and parsed, |
74 | | - and ordered by filename (without the directory prefix). For each configuration file, |
75 | | - drop-in files are looked for in directories with same name as the configuration file |
76 | | - with a suffix ".d" added.</para></listitem> |
77 | | - |
78 | | - <listitem><para>The partition table already existing on the block device is loaded and |
79 | | - parsed.</para></listitem> |
80 | | - |
81 | | - <listitem><para>The existing partitions in the partition table are matched up with the |
82 | | - <filename>repart.d/*.conf</filename> files by GPT partition type UUID. The first existing partition |
83 | | - of a specific type is assigned the first configuration file declaring the same type. The second |
84 | | - existing partition of a specific type is then assigned the second configuration file declaring the same |
85 | | - type, and so on. After this iterative assigning is complete any left-over existing partitions that have |
86 | | - no matching configuration file are considered "foreign" and left as they are. And any configuration |
87 | | - files for which no partition currently exists are understood as a request to create such a partition. |
| 76 | + <listitem><para>The <filename>repart.d/*.conf</filename> configuration files are loaded and parsed, and |
| 77 | + ordered by filename (without the directory prefix). For each configuration file, drop-in files are |
| 78 | + loaded from directories with same name as the configuration file with the suffix ".d" added. |
| 79 | + </para></listitem> |
| 80 | + |
| 81 | + <listitem><para>The partition table on the block device is loaded and parsed, if present. |
88 | 82 | </para></listitem> |
89 | 83 |
|
| 84 | + <listitem><para>The existing partitions in the partition table are matched with the |
| 85 | + <filename>repart.d/*.conf</filename> files by GPT partition type UUID. The first existing partition of |
| 86 | + a specific type is assigned the first configuration file declaring the same type. The second existing |
| 87 | + partition of a specific type is then assigned the second configuration file declaring the same type, |
| 88 | + and so on. After this iterative assigning is complete, any existing partitions that have no matching |
| 89 | + configuration file are considered "foreign" and left as they are. And any configuration files for which |
| 90 | + no partition was matched are treated as requests to create a partition.</para></listitem> |
| 91 | + |
90 | 92 | <listitem><para>Partitions that shall be created are now allocated on the disk, taking the size |
91 | 93 | constraints and weights declared in the configuration files into account. Free space is used within the |
92 | 94 | limits set by size and padding requests. In addition, existing partitions that should be grown are |
|
124 | 126 | partition table.</para></listitem> |
125 | 127 | </orderedlist> |
126 | 128 |
|
127 | | - <para>As exception to the normally strictly incremental operation, when called in a special "factory |
128 | | - reset" mode, <command>systemd-repart</command> may also be used to erase existing partitions to |
129 | | - reset an installation back to vendor defaults. This mode of operation is used when either the |
130 | | - <option>--factory-reset=yes</option> switch is passed on the tool's command line, or the |
131 | | - <option>systemd.factory_reset=yes</option> option specified on the kernel command line, or the |
132 | | - <varname>FactoryReset</varname> EFI variable (vendor UUID |
| 129 | + <para>As an exception to the normal incremental operation, when called in a special "factory reset" mode, |
| 130 | + <command>systemd-repart</command> may be used to erase existing partitions to reset an installation back |
| 131 | + to vendor defaults. This mode of operation is used when either the <option>--factory-reset=yes</option> |
| 132 | + switch is passed on the tool's command line, or the <option>systemd.factory_reset=yes</option> option is |
| 133 | + specified on the kernel command line, or the <varname>FactoryReset</varname> EFI variable (vendor UUID |
133 | 134 | <constant>8cf2644b-4b0b-428f-9387-6d876050dc67</constant>) is set to "yes". It alters the algorithm above |
134 | 135 | slightly: between the 3rd and the 4th step above any partition marked explicitly via the |
135 | 136 | <varname>FactoryReset=</varname> boolean is deleted, and the algorithm restarted, thus immediately |
|
153 | 154 | from a common seed images prepared with this tool become reproducible and the result of the algorithm |
154 | 155 | above deterministic.</para> |
155 | 156 |
|
156 | | - <para>The positional argument should specify the block device to operate on. Instead of a block device |
157 | | - node path a regular file may be specified too, in which case the command operates on it like it would if |
158 | | - a loopback block device node was specified with the file attached. If <option>--empty=create</option> is |
159 | | - specified the specified path is created as regular file, which is useful for generating disk images from |
160 | | - scratch.</para> |
| 157 | + <para>The positional argument should specify the block device or a regular file to operate on. If |
| 158 | + <option>--empty=create</option> is specified, the specified path is created as regular file, which is |
| 159 | + useful for generating disk images from scratch.</para> |
161 | 160 | </refsect1> |
162 | 161 |
|
163 | 162 | <refsect1> |
|
168 | 167 | <variablelist> |
169 | 168 | <varlistentry> |
170 | 169 | <term><option>--dry-run=</option></term> |
| 170 | + |
171 | 171 | <listitem><para>Takes a boolean. If this switch is not specified <option>--dry-run=yes</option> is |
172 | 172 | the implied default. Controls whether <filename>systemd-repart</filename> executes the requested |
173 | 173 | re-partition operations or whether it should only show what it would do. Unless |
|
179 | 179 |
|
180 | 180 | <varlistentry> |
181 | 181 | <term><option>--empty=</option></term> |
| 182 | + |
182 | 183 | <listitem><para>Takes one of <literal>refuse</literal>, <literal>allow</literal>, |
183 | 184 | <literal>require</literal>, <literal>force</literal> or <literal>create</literal>. Controls how to |
184 | 185 | operate on block devices that are entirely empty, i.e. carry no partition table/disk label yet. If |
|
589 | 590 | <refsect1> |
590 | 591 | <title>Exit status</title> |
591 | 592 |
|
592 | | - <para>On success, 0 is returned, a non-zero failure code otherwise.</para> |
| 593 | + <para>On success, 0 is returned, and a non-zero failure code otherwise.</para> |
593 | 594 | </refsect1> |
594 | 595 |
|
595 | 596 | <refsect1> |
|
601 | 602 | <para>The following creates a configuration extension DDI (confext) for an |
602 | 603 | <filename>/etc/motd</filename> update:</para> |
603 | 604 |
|
604 | | - <programlisting>mkdir tree tree/etc tree/etc/extension-release.d |
605 | | -echo "Hello World" > tree/etc/motd |
606 | | -cat > tree/etc/extension-release.d/extension-release.my-motd <<EOF |
| 605 | + <programlisting>mkdir -p tree/etc/extension-release.d |
| 606 | +echo "Hello World" >tree/etc/motd |
| 607 | +cat >tree/etc/extension-release.d/extension-release.my-motd <<EOF |
607 | 608 | ID=fedora |
608 | 609 | VERSION_ID=38 |
609 | 610 | IMAGE_ID=my-motd |
610 | 611 | IMAGE_VERSION=7 |
611 | 612 | EOF |
612 | | -systemd-repart -C --private-key=privkey.pem --certificate=cert.crt -s tree/ /var/lib/confexts/my-motd.confext.raw |
| 613 | +systemd-repart -C \ |
| 614 | + --private-key=privkey.pem \ |
| 615 | + --certificate=cert.crt \ |
| 616 | + -s tree/ \ |
| 617 | + /var/lib/confexts/my-motd.confext.raw |
613 | 618 | systemd-confext refresh</programlisting> |
614 | 619 |
|
615 | 620 | <para>The DDI generated that way may be applied to the system with |
|
0 commit comments