Skip to content

gpt-auto-generator: be more defensive when checking the presence of E… - #31181

Merged
YHNdnzj merged 2 commits into
systemd:mainfrom
fbuihuu:gpt-auto-more-defensive
Feb 12, 2024
Merged

YHNdnzj merged 2 commits into
systemd:mainfrom
fbuihuu:gpt-auto-more-defensive

Conversation

@fbuihuu

@fbuihuu fbuihuu commented Feb 2, 2024

Copy link
Copy Markdown
Contributor

…SP in fstab

Looking for the ESP node is useful to shortcut things but if we're told that the node is not referenced in fstab that doesn't necessarily mean that ESP is not mounted via fstab. Indeed the check is not reliable in all cases. Firstly because it assumes that udev already set the symlinks up. This is not the case for initrd-less boots. Secondly the devname of the ESP partition can be wrongly constructed (e.g. multipath). Hence we need to be defensive here and also verify the paths of the mount point directory.

@github-actions github-actions Bot added the please-review PR is ready for (re-)review by a maintainer label Feb 2, 2024
@YHNdnzj

YHNdnzj commented Feb 2, 2024

Copy link
Copy Markdown
Member

Sorry, but I'm still not convinced. My argument in #30994 (comment) still stands.

Secondly the devname of the ESP partition can be wrongly constructed (e.g. multipath).

What is this supposed to mean? Please elaborate. Note that devnode_same stat()s the device, it's hence NOT a path-only comparison.

@poettering

Copy link
Copy Markdown
Member

So I think it would be OK to mount neither ESP nor XBOOTLDR automatically if any path that starts with /efi or /boot exists in fstab.

i.e. I think people should either configure their boot partitions in full in fstab or not at all in fstab. We should not bother with a case where one is configured explicitly and the other shall be mounted automatically. That's just doomed to fail I think.

But please make this a nice helper call that prefix checks both dirs with path_startswith() in fstab, and returns a result.

@fbuihuu

fbuihuu commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

Great, that's even simpler. I'll rework the patch accordingly.

@fbuihuu

fbuihuu commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

What is this supposed to mean? Please elaborate. Note that devnode_same stat()s the device, it's hence NOT a path-only comparison.

It means that the naive approche that consists in adding 'p' suffix to the disk dev name that contains the partitions doesn't work for DM devices. For example, dm-0p2 isn't a valid device name for DM devices.

Comment thread src/shared/fstab-util.c Resolved
@fbuihuu
fbuihuu force-pushed the gpt-auto-more-defensive branch from a29c781 to 0ac909e Compare February 7, 2024 13:21
Comment thread src/shared/fstab-util.c Resolved
Comment thread src/shared/fstab-util.c Resolved
Comment thread src/shared/fstab-util.c Resolved
Comment thread src/shared/fstab-util.c Resolved
@poettering

Copy link
Copy Markdown
Member

Would love @keszybz' take on the situation before we merge this. @keszybz after all most recently changed the logic around.

@poettering poettering added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Feb 7, 2024
@poettering
poettering requested a review from keszybz February 7, 2024 17:29

@keszybz keszybz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the simplicity of this approach. I guess that if we were doing this for the first, I would certainly prefer it. But we're not, so it's possible that there are people out there who are relying on the details of the previous behaviour. It's impossible to say for certain… But I think it's worth trying: let's merge this and later add a verbose entry in NEWS about changed behaviour and hope for the best. If reports from unhappy users start pouring in, we will have to revisit the issue.

Comment thread src/shared/fstab-util.c Resolved
@keszybz

keszybz commented Feb 8, 2024

Copy link
Copy Markdown
Member

I think we also need a mention in the man page. It currently says

It will also not create mount point configuration for directories which already contain files or if the mount point is explicitly configured in fstab(5).

but this patch does something more.

@fbuihuu

fbuihuu commented Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

It will also not create mount point configuration for directories which already contain files or if the mount point is explicitly configured in fstab(5).

Is this statement actually true ?

I don't see what would prevent the generator from creating a mount unit for /srv if this mount point was listed in fstab for example.

@fbuihuu
fbuihuu force-pushed the gpt-auto-more-defensive branch from 0ac909e to d17079f Compare February 9, 2024 16:32
@github-actions github-actions Bot added documentation please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Feb 9, 2024
Comment thread NEWS Resolved
Comment thread NEWS Resolved
Comment thread man/systemd-gpt-auto-generator.xml Resolved
@poettering poettering added good-to-merge/with-minor-suggestions and removed please-review PR is ready for (re-)review by a maintainer labels Feb 9, 2024

@YHNdnzj YHNdnzj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…SP in fstab

Looking for the ESP node is useful to shortcut things but if we're told that
the node is not referenced in fstab that doesn't necessarily mean that ESP is
not mounted via fstab. Indeed the check is not reliable in all cases. Firstly
because it assumes that udev already set the symlinks up. This is not the case
for initrd-less boots. Secondly the devname of the ESP partition can be wrongly
constructed by the dissect code. For example, the approach which consists in
appending "p<partnum>" suffix to construct the partition devname from the disk
devname doesn't work for DM devices.

Hence this patch makes the logic more defensive and do not mount neither ESP
nor XBOOTLDR automatically if any path in paths that starts with /efi or /boot
exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants