-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sysroot: Support /boot on root or as seperate filesystem for syslinux and u-boot #2149
sysroot: Support /boot on root or as seperate filesystem for syslinux and u-boot #2149
Conversation
Reduce duplication.
7db8cab
to
35e77a0
Compare
… and u-boot We use a similar trick to having a `sysroot -> .` symlink on the real root here to support both /boot on root as well as on a separate filesystem. No matter how it's mounted `/boot/xyz` will always refer to the file you'd expect. This is nicer than my previous attempts at this because there's no configuration nor auto-detection required.
35e77a0
to
0ced9fd
Compare
jenkins ci is failing with the same issue that is currently plaguing master:
but I consider this ready for review. If this goes in I'll be glad to close the PRs with the other attempts :). I've only tested this on real systems with /boot on root and in syslinux mode. Our systems have u-boot, but they read the syslinux config. |
"\yeah, i'm really need this too as i have /boot on root |
CI is passing now, presumably thanks to #2151. Thanks @jlebon and @cgwalters. |
@@ -1998,6 +1998,12 @@ prepare_new_bootloader_link (OstreeSysroot *sysroot, | |||
g_assert ((current_bootversion == 0 && new_bootversion == 1) || | |||
(current_bootversion == 1 && new_bootversion == 0)); | |||
|
|||
/* This allows us to support both /boot on a seperate filesystem to / as well | |||
* as on the same filesystem. */ | |||
if (TEMP_FAILURE_RETRY (symlinkat (".", sysroot->sysroot_fd, "boot/boot")) < 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the simplicity of this is clearly tempting. I think what I'm pausing on here though is that so far libostree doesn't really create files except in a few places.
But...I just want to revisit again, were we overthinking this previously around detecting /boot
being a mount point? Can't we just statvfs(/)
and statvfs(/boot)
and check the device IDs?
Passing down a boolean for that to the bootloader generation shouldn't be too hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: Btrfs
statfs() f_fsid will be different per subvolume on the same file system. The first half (8 nibbles?) of the ID reported by stat -f
seems to be consistent regardless of subvolume, but I'm not certain if the 2nd half of the ID can "roll over" once subvol ID's get high enough.
inode 256 is reserved for Btrfs subvolumes, i.e. if the file system is btrfs and the inode is 256, then it is a subvolume (or snapshot).
mountpoint -d
returns the same value for each mountpoint that's the same Btrfs file system, even when backed by different subvolumes. This value looks like MAG:MIN but it doesn't match the MAG:MIN if the actual physical device partition.
Maybe more challenging is that a subvolume could be named anything and exist anywhere on a Btrfs file system, and yet mounted at /boot. This is relevant because this path to subvolume is what's needed for the bootloader to find it. I see BTRFS_IOC_INO_LOOKUP and BTRFS_IOC_TREE_SEARCH ioctl's used by btrfs subvolume list
command.
Updated: There are other combinations. /boot could be a directory on a subvolume 'fedora33root'. It could also be a nested subvolume inside 'fedora33root'. Neither of these /boot are mounted. mount
does show the "path to subvolume" for any mountpoint using Btrfs. Simplistically, if statfs() says vmlinuz/initramfs are on Btrfs, and somehow have f_fsid turned into a path-to-subvolume for the bootloader config. The mount
command shows this path to subvolume for any mountpoint using btrfs - so path to kernel+initrd could be inferred.
Thanks a lot for working on this BTW! |
To be clear I'm leaning towards #2145 but also happy to continue discussion. |
AIUI Could you expand on the reasoning for this policy? I'm having difficulty thinking of downsides. An alternative would be to check for the
I think there's a general problem that the system that is running I ran into this when working on #1404, which prompted the creation of #2145 - which, as you say, makes things explicit. There's more discussion here: #1404 (comment)
I have a preference for this one rather than #2145 because:
I think there are some commits in #2145 that would be worth salvaging, like the |
@martinezjavier do you have an opinion on this one? |
I think that I'm leaning towards this PR instead of #2125, not only because is simpler as you mentioned which is appealing but also because this issue is also present for GRUB. GRUB expects the kernel and initrd images to be loaded from a path relative to the root of the partition where these are located. For example the
because the kernel and initrd images are in the
The GRUB By having the So my suggestion would be to not make this something specific to syslinux and u-boot but instead add the prefix to the BLS snippets. That way I remember there was a similar issue with the As @wmanley mentioned, OSTree already relies heavily on symlinks. Adding another one to cover this case doesn't seem that bad to me. |
I think I'd be a lot happier with this if this symlink wasn't something we invented in ostree, but e.g. something upstream bootloader maintainers recommended to create as well. I have no idea how to drive that consensus though. |
OK restarted the CI |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cgwalters, wmanley The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
So will it work for grub also? |
I'm sure it could be made to work for grub, but I haven't changed anything WRT grub here. I'd expect the equivalent change for grub to be straightforward. |
So...hmm, I think what we didn't end up doing here is this part:
? |
Yeah, it seems that was not done. |
PR in #2705 |
We use a similar trick to having a
sysroot -> .
symlink on the real roothere to support both /boot on root as well as on a separate filesystem. No
matter how it's mounted
/boot/xyz
will always refer to the file you'dexpect.
This is nicer than my previous attempts at this because there's no
configuration nor auto-detection required.
Fixes #1452
Replaces #1404, #1914 and #2145