[systemd-devel] How to use systemd-repart partitions?
Lennart Poettering
lennart at poettering.net
Tue May 19 21:26:27 UTC 2020
On Di, 19.05.20 23:05, Tobias Hunger (tobias.hunger at gmail.com) wrote:
> 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.
So, yes, "systemd-makefs" was how I intended this originally to be
done. However, I think that's not going to suffice in the long run,
and instead systemd-repart will soon be able to format file systems
natively by invoking mkfs.<xyz>. For the following reasons:
1. Something I find particularly sexy: this way we can format the
partitions before writing the partition table. This means if we get
aborted in the middle the partition table will remain as it was
before, and on next boot we can try again. This means formatted
partitions can pop into existance at the moment the partition table
is written and not a moment before, thus providing truly atomic
behaviour where there's a clear point in time where nothing exists
yet, and then suddenly everything exists, fully set up. This is how
robust partitioning really should look like I think.
2. We should support setting up encryption, too. But if we do that,
then x-systemd.makefs is not going to work anyway, because we need
to do the LUKS stuff first, but if we do LUKS in repart, we might
as well do mkfs.
3. This way we can also derive the fs UUIDs by hashing from the
machine ID, like we already do for the partition UUIDs. which makes
everything even more deterministic, which I like.
4. I want to cover the usecase where /usr/ is an immutable (verity
verified even) image, and the root fs is created on first boot as
writable fs, and then combined with /usr. This kind of setup means
the initrd must already format the root fs, and x-systemd.makefs
doesn't really cover that so nicely, since its run after the
transition to the host fs.
Long story short: expect new settings FileSystemType= and Encrypt=
soon in /etc/repart.d/*.conf files soon. It's high on my TODO list.
> 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.
Yes, I guess we can make that available. Please file an RFE
issue. Even better, provide a patch!
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list