[systemd-devel] How to use systemd-repart partitions?
Tobias Hunger
tobias.hunger at gmail.com
Tue May 19 21:05:57 UTC 2020
Hello!
I am experimenting with automatically partitioning, formatting and
creating files on a new drive based on configuration. Systemd comes
with all the building blocks nowadays to do this, but I am still
struggling a bit.
I have created some partition definitions and ran systemd-repart to
partition a drive according to those definitions. I am currently
experimenting in QEMU, so I run this command:
`system-repart --dry-run=no --empty=require /dev/vda`
to partition the new drive. That works nicely. Now how do I format
those partitions? Systemd-mkfs springs to mind -- so I will need to
identify those partitions in /etc/fstab. My system is immutable, so I
have to create /etc/fstab at the same time I create the various
partition definition files in /usr/lib/repart.d.
What is the best way to do so?
These are the options I see:
* Partition numbers (the X in /dev/vdaX)
* PARTUUID and
* PARTLABEL
The partition number seems unreliable: Systemd-repart may leave out
some low-priority partitions, which will shift down any partition
defined later than the one left out.
The partition UUID is calculated by systemd-repart based on
machine-id, partition type and position in the GPT (relative to other
partitions of the same type). But how can I calculate those UUIDs
before running systemd-repart? There is also the problem that the
partition UUID may also change when systemd-repart leaves out some
partitions of the same type. Not perfect either.
The partition label can be provided in the partition definition file,
so this is the only piece of information I can have before running
systemd-repart! But labels are prone to be short human-relevant
strings -- and those tend to get reused in several places, etc. and
udev ends up deduplicating the names. So those are more reliable than
partition numbers, but not 100% reliable either.
So far the only way I see is to set a random Label on my partitions so
that I can put PARTLABEL=esp_a8322bf91e into /etc/fstab, combining the
label with a UUID of my own making stored in the partititons .conf
file.
Would it maybe make sense to add a way to provide the partition UUID
via the partitions .conf file as well? That way I would not need to
add a UUID-part to my labels.
Best Regards,
Tobias
More information about the systemd-devel
mailing list