Repository navigation
Description
systemd version the issue has been seen with
256
Used distribution
Fedora rawhide
Linux kernel version used
6.12.0-0.rc5.20241101git6c52d4da1c74.48.fc42.x86_64
CPU architectures issue was seen on
x86_64
Component
systemd-gpt-auto-generator
Expected behaviour you didn't see
According to the manpage:
This generator will only look for the root partition on the same physical disk where the EFI System Partition (ESP) is located. Note that support from the boot loader is required: the EFI variable LoaderDevicePartUUID of the 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f vendor UUID is used to determine from which partition, and hence the disk, from which the system was booted. If the boot loader does not set this variable, this generator will not be able to detect the root partition.
Similarly, this generator will only look for the other partitions on the same physical disk as the root partition. In this case, boot loader support is not required. These partitions will not be searched for on systems where the root file system is distributed on multiple disks, for example via btrfs RAID.
By my reading this sounds like systemd will look at the GPT on the physical drive where the ESP is, as told by the bootloader. The language below mentions "other partitions" and "root file system on multiple disks". This is where the logic indeed goes somewhat sideways.
I am using systemd-boot and the LoaderDevicePartUUID variable is correctly set. I also have /dev/gpt-auto-root pointing at the "real" root device that was detected in the initramfs. In the meantime, though, I've remounted a composefs on /sysroot before booting the main system. When the gpt generator runs it has this output:
[root@fedora ~]# SYSTEMD_LOG_LEVEL=debug /usr/lib/systemd/system-generators/systemd-gpt-auto-generator /tmp/x
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Reading EFI variable /sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
Adding /: /dev/gpt-auto-root fstype=(any)
Neither root nor /usr/ file system are on a (single) block device.
Skipping automatic GPT dissection logic, root file system not backed by a (single) whole block device.
The mention of "Reading EFI variable..." is caused by this code:
r = efi_loader_get_device_part_uuid(NULL);
if (r == -ENOENT) {
log_notice("EFI loader partition unknown, exiting.\n"
"(The boot loader did not set EFI variable LoaderDevicePartUUID.)");which is really only checking if the variable is set, not reading/using it (note the NULL). After the variable is verified as present then the generator goes down an entirely different logical path involving trying to detect the block device of the / partition and using the GPT found on that disk. If it can't do that, it tries /usr. It'll also look at the /run/systemd/volatile-root symlink if it exists.
Importantly, if it fails to figure out the root device this way, it goes no further. It doesn't try to read the LoaderDevicePartUUID variable again (which is actually only used as a double-check after the data is read from the partition table).
By my reading of the docs, this is wrong. The docs say that the device that is searched is the one with the ESP, but in fact, it's the one that has the block device behind the mount of /. At the very least, the actual direction that this process happens in should probably be more clearly documented.
It's also a bit strange that the code in blockdev-util.c which tries to determine the root block device by looking at /, /usr/ and /run/systemd/volatile-root doesn't contain an attempt to look at /dev/gpt-auto-root, which would have worked in my case.
So I guess two asks:
- clearer docs (would have saved me quite a bit of time tracking this down)
- better detection for my case: it should be enough to just look directly at
/dev/gpt-auto-rootif it exists — in fact, this seems like the "most obvious" option if we're not gonna actually start withLoaderDevicePartUUID.
Unexpected behaviour you saw
No response
Steps to reproduce the problem
No response
Additional program output to the terminal or log subsystem illustrating the issue
No response
Activity
[-]systemd-gpt-auto-generator can't find EFI because it can't detect blockdev of /[/-][+]systemd-gpt-auto-generator can't find ESP because it can't detect blockdev of /[/+]allisonkarlitskaya commentedon Nov 4, 2024
I'm dealing with this for now by
stat()ing/dev/gpt-auto-rootand writing the/dev/block/x:ysymlink to/run/systemd/volatile-root, but this is clearly just a workaround.poettering commentedon Nov 5, 2024
"composefs" means just another overlayfs, right?
allisonkarlitskaya commentedon Nov 5, 2024
More or less, ya. It's an overlayfs where the upper is a erofs image and the datadir is indeed a pointer back to the underlying "real" filesystem.
poettering commentedon Nov 5, 2024
overlayfs doesn#t provide an API for us to query backing layers, hence the /dev/gpt-auto-root thing is currently the way to go.
allisonkarlitskaya commentedon Nov 6, 2024
Would you take a patch to
blockdev-util.ctostat("/dev/gpt-auto-root")to get therdev?allisonkarlitskaya commentedon Nov 6, 2024
Even this seems like a bit of a hack, to be honest, though. What should really be happening (to match my impression from reading the docs) is not that we look at the block device backing
/but we should rather look at/dev/disk/by-partuuid/${LoaderDevicePartUUID}and start the search from there...[-]systemd-gpt-auto-generator can't find ESP because it can't detect blockdev of /[/-][+]systemd-gpt-auto-generator can't find ESP because it can't detect blockdev of / if composefs is used[/+]prepare-root: create /run/systemd/volatile-root for composefs
initramfs: tolerate pre-existing /run/systemd/volatile-root symlink
setup-root: Tolerate pre-existing /run/systemd/volatile-root symlink