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