Repository navigation
efi: use a mounted ESP only for itself when other ESPs are written - #1195
LorbusChris wants to merge 5 commits into
Conversation
|
Hi @LorbusChris. Thanks for your PR. I'm waiting for a coreos member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
9ca14c1 to
3479bbd
Compare
The EFI component is installed to every given device that has an ESP. The disks of a firmware RAID array, such as Intel VROC, share one ESP on the array, which find_partition_of_esp() finds from each of them, so install copied the payload to it once for each disk. Install to each ESP once, from the first device that leads to it. Move the choice of devices into a function to test it, with lsblk output from bootc's blockdev crate for a firmware RAID array and for a software RAID1 root whose disks have an ESP each. Assisted-by: LLM
With --update-firmware, install updates the firmware's boot entries for each ESP it installs to: it deletes the entries labelled with the product name, then creates one for that ESP. With an ESP on each of two disks, the second ESP's update deleted the first ESP's entry, so the firmware could only boot from the last disk. Delete the old entries only before the first ESP's entry, so that every ESP keeps one and the firmware can fall back to another disk. A later install still replaces all of them. Assisted-by: LLM
On a system with an ESP on each disk, such as one with a RAID1 root, install copies shim and GRUB to every ESP, but wrote EFI/<vendor>/grub.cfg and bootuuid.cfg only into the ESP that the EFI component had mounted last. GRUB booted from any other disk found no config and dropped to its rescue shell. Write the static configs in /boot once, before installing the components, and the EFI ones into each ESP right after installing the EFI component there, while it is mounted. /boot is synced again after all components, as before, for what grub2-install writes there. grubconfigs::install() now leaves the EFI ones to StaticConfigs::install_efi(), which takes the ESP's EFI directory. That also fixes adopt-and-update --with-static-config, which since 883c7a8 passed EFI/<vendor> where the ESP's root was expected, and so failed, trying to write EFI/<vendor>/EFI/<vendor>/grub.cfg. On x86_64, /boot/grub2 is now created by bootupd with mode 0700, as on the other architectures and as CentOS Stream 10's grub2-common ships it, rather than by grub2-install with 0755. The static configs are still not tracked, so an update does not repair an ESP that lacks them. Based on coreos#1077. Fixes: coreos#1076 Co-authored-by: ckyrouac <ckyrouac@redhat.com> Assisted-by: LLM
install writes GRUB's static configs to each ESP inside its per-device loop, which no test ran: bootc-e2e installs to one disk. Install the EFI component onto two loopback disks with an ESP each and the root on the first, and check that both ESPs get shim, grub.cfg and a bootuuid.cfg naming the root's filesystem. Only the legs without grub-cc run it, as the static configs are GRUB's. Assisted-by: LLM
On a system with an ESP on each disk, install, update, adoption, validation and the ESP's state file go through the ESPs one by one, but each turn used whichever ESP was mounted at boot/efi, efi or boot under the root, whatever device it was for. With the first disk's ESP mounted at /boot/efi, that ESP was written once per disk, and the other disks' ESPs were never written or checked. Decide from all the ESPs being written to: those behind the root, or for install, those of the devices it was given. - The mounted ESP is used for the ESP it is: the same device, an array holding it, as with an md RAID1 array of ESP partitions, whose members are what the ESP lookup finds, or a partition of such an array. - Another of the ESPs is mounted on its own, unless it is a RAID member, which is never mounted bypassing its array. - If the mounted ESP is none of them, it is used for all of them, as before: the system uses an ESP from elsewhere, such as another disk. - An ESP that can't be checked, because its device or sysfs can't be inspected, counts as the mounted one, as before. ESPs that bootupd used to skip this way may be empty, stale, or another system's. So, for an ESP mounted on its own: - Update, adoption, validation and the state file skip it, with a warning, if it can't be mounted or read, or holds none of the installed files outside EFI/BOOT. For the state file, those are the files it records, or without them, any EFI directory. - Update writes every file of the update that the ESP lacks or has otherwise, not just those that changed, and removes those the update drops. Until then, validation reports what an older update left. - Install, which fills it, falls back to the mounted ESP, as before, if it can't be mounted. Install runs once per device, so the per-device loop hands it the ESPs of all devices; without them, a mounted ESP is used as before. The state file is still read from a mounted ESP if there is one. Assisted-by: LLM
prestist
left a comment
There was a problem hiding this comment.
This looks right to me, but I'll hold the approval until it's out of draft. I
traced the layouts in the table through MountedEsp::of and
is_held_by, and the update, validate, adoption and state-file loops all
unmount between ESPs, so the choice is recomputed for each one. CI is green at
3479bbd and the tests pass locally.
Two things:
-
The helper tests cover the matching and
sync_diff_to, but
mount_installed_esp's skip path and install's per-device choice are only
covered by the loop-device checks. Could that be a unit test, or is real
mounting the blocker? -
mount_installed_esptrustsensure_mounted_esp's early return: if a
mountpoint is already set, it returns it without re-running theMountedEsp
decision, andbeside_mounted_espcan be stale. The current callers unmount
between ESPs, so it is fine today, but should it assert that the mountpoint
belongs to the ESP it was asked for?
Nit: the skip check looks at file names only, so an ESP holding another system's
EFI/<vendor> files looks like ours and gets updated. I assume that is
deliberate given find_colocated_esps limits the ESPs to the root's disks, but
it is worth saying.
Assisted-by: AI tooling
3479bbd to
feddbd2
Compare
Stacked on #1194; only the last commit is new here.
On a system with an ESP on each disk, such as an mdadm RAID1 root, bootupd goes through the ESPs one by one: in
install(once per device),update, adoption,validate, and when writing the ESP's state file. For each one, though,mount_esp_device()andensure_mounted_esp()first looked for an ESP mounted atboot/efi,efiorbootunder the root, and used it whatever device they were asked for. With disk A's ESP mounted at/boot/efi, on a booted system or in an installer that mounts the target's/boot/efibefore runningbootupctl backend install, A's ESP was written once per disk, and B's was never written or checked. Installs without a mounted ESP, such as bootc's, weren't affected.Checking only whether the mounted ESP is on the device asked for would break layouts that work today. So the choice now looks at all the ESPs being written to: those behind the root, or for
install, those of the devices it was given./sys/dev/block/MAJ:MIN/holders), or of a partition of such an array.update, adoption,validateand the state file skip it, with a warning once per ESP, if it can't be mounted or holds none of the installed files outsideEFI/BOOT;updatebrings all of it up to date, not just the files that changed in this update, so that a stale copy converges. Until the next update,validatereports what an older update left there;install, which fills it, falls back to the mounted ESP, as before, if it can't be mounted.installruns once per device, so the per-device loop inbootupd.rshands it the ESPs of all devices first. Without them, a mounted ESP is used as before.Testing
Unit tests:
Breaking the RAID-member rule, the partition match or the
EFI/BOOTexclusion each fails a test.With real devices: two vfat loop devices, A mounted at
<root>/efi.fmt, test and clippy pass. All changed call sites are under
cfg(efi_arch), so s390x and ppc64le are unaffected.Not tested: md RAID1 and firmware RAID arrays on real hardware, and the full
updateandinstallflows on two disks.Related: #1059 (with firmware RAID, a member disk was mounted instead of the array's ESP partition), #1076.
Assisted-by: LLM