/etc/repart.d/*.conf /run/repart.d/*.conf /usr/lib/repart.d/*.conf
repart.d/*.conf files describe basic properties of partitions of block devices of the local system. They may be used to declare types, names and sizes of partitions that shall exist. The systemd-repart(8) service reads these files and attempts to add new partitions currently missing and enlarge existing partitions according to these definitions. Operation is generally incremental, i.e. when applied, what exists already is left intact, and partitions are never shrunk, moved or deleted.
These definition files are useful for implementing operating system images that are prepared and delivered with minimally sized images (for example lacking any state or swap partitions), and which on first boot automatically take possession of any remaining disk space following a few basic rules.
Currently, support for partition definition files is only implemented for GPT partitition tables.
Partition files are generally matched against any partitions already existing on disk in a simple algorithm: the partition files are sorted by their filename (ignoring the directory prefix), and then compared in order against existing partitions matching the same partition type UUID. Specifically, the first existing partition with a specific partition type UUID is assigned the first definition file with the same partition type UUID, and the second existing partition with a specific type UUID the second partition file with the same type UUID, and so on. Any left-over partition files that have no matching existing partition are assumed to define new partition that shall be created. Such partitions are appended to the end of the partition table, in the order defined by their names utilizing the first partition slot greater than the highest slot number currently in use. Any existing partitions that have no matching partition file are left as they are.
Note that these partition definition files do not describe the contents of the partitions, such as the file system used. Separate mechanisms, such as systemd-growfs(8) and systemd-makefs maybe be used to initialize or grow the file systems inside of these partitions.
Table 1. GPT partition type identifiers
EFI System Partition
Extended Boot Loader Partition
Home (/home/) partition
Server data (/srv/) partition
Variable data (/var/) partition
Temporary data (/var/tmp/) partition
Generic Linux file system partition
Root file system partition type appropriate for the local architecture (an alias for an architecture root file system partition type listed below, e.g. root-x86-64)
Verity data for the root file system partition for the local architecture
Root file system partition of the secondary architecture of the local architecture; usually the matching 32bit architecture for the local 64bit architecture)
Verity data for the root file system partition of the secondary architecture
Root file system partition for the x86 (32bit, aka i386) architecture
Verity data for the x86 (32bit) root file system partition
Root file system partition for the x86_64 (64bit, aka amd64) architecture
Verity data for the x86_64 (64bit) root file system partition
Root file system partition for the ARM (32bit) architecture
Verity data for the ARM (32bit) root file system partition
Root file system partition for the ARM (64bit, aka aarch64) architecture
Verity data for the ARM (64bit, aka aarch64) root file system partition
Root file system partition for the ia64 architecture
Verity data for the ia64 root file system partition
This setting defaults to linux-generic.
Most of the partition type UUIDs listed above are defined in the m[blue]Discoverable Partitions Specificationm.
The Weight= setting is used to distribute available disk space in an "elastic" fashion, based on the disk size and existing partitions. If a partition shall have a fixed size use both SizeMinBytes= and SizeMaxBytes= with the same value in order to fixate the size to one value, in which case the weight has no effect.
Padding is useful if empty space shall be left for later additions or a safety margin at the end of the device or between partitions.
Example 1. Grow the root partition to the full disk size at first boot
With the following file the root partition is automatically grown to the full disk if possible during boot.
# /usr/lib/repart.d/50-root.conf [Partition] Type=root
Example 2. Create a swap and home partition automatically on boot, if missing
The home partition gets all available disk space while the swap partition gets 1G at most and 64M at least. We set a priority > 0 on the swap partition to ensure the swap partition is not used if not enough space is available. For every three bytes assigned to the home partition the swap partition gets assigned one.
# /usr/lib/repart.d/60-home.conf [Partition] Type=home
# /usr/lib/repart.d/70-swap.conf [Partition] Type=swap SizeMinBytes=64M SizeMaxBytes=1G Priority=1 Weight=333
Example 3. Create B partitions in an A/B Verity setup, if missing
Let's say the vendor intends to update OS images in an A/B setup, i.e. with two root partitions (and two matching Verity partitions) that shall be used alternatingly during upgrades. To minimize image sizes the original image is shipped only with one root and one Verity partition (the "A" set), and the second root and Verity partitions (the "B" set) shall be created on first boot on the free space on the medium.
# /usr/lib/repart.d/50-root.conf [Partition] Type=root SizeMinBytes=512M SizeMaxBytes=512M
# /usr/lib/repart.d/60-root-verity.conf [Partition] Type=root-verity SizeMinBytes=64M SizeMaxBytes=64M
The definitions above cover the "A" set of root partition (of a fixed 512M size) and Verity partition for the root partition (of a fixed 64M size). Let's use symlinks to create the "B" set of partitions, since after all they shall have the same properties and sizes as the "A" set.
# ln -s 50-root.conf /usr/lib/repart.d/70-root-b.conf # ln -s 60-root-verity.conf /usr/lib/repart.d/80-root-verity-b.conf