From 7768026f12beb76aaf01cf831431cd1e7abde095 Mon Sep 17 00:00:00 2001 From: aboba Date: Thu, 30 Jul 2026 16:23:43 +0200 Subject: [PATCH] Fix IOMMU step aborting the install on Fedora MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit configure_iommu_grub preferred /boot/efi/EFI/*/grub.cfg, but on Fedora that path is a 159-byte stub that chainloads /boot/grub2/grub.cfg. grub2-mkconfig refuses to overwrite it and exits non-zero, and since install.sh runs under set -e the whole installer died there — after the modules were installed but before the final summary, leaving /etc/default/grub edited and grub.cfg untouched. That staged edit would then activate silently at the next kernel update. Prefer /boot/grub2/grub.cfg when it exists, fall back to the EFI path for older layouts, and treat a failed regeneration as a warning rather than a fatal error: by that point the modules are already in place. Also patch existing BLS entries with grubby. Regenerating grub.cfg only affects entries created afterwards, so on a BLS system the parameters never reached the kernel that was actually booting. --- install.sh | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index f5656a3..6949a82 100755 --- a/install.sh +++ b/install.sh @@ -389,22 +389,56 @@ configure_iommu_grub() { fi ok "Set ${key}=\"${merged}\" (backup: ${grub_file}.cmpunlocker.bak)" + local regen_ok=1 if command -v update-grub &>/dev/null; then - update-grub + update-grub || regen_ok=0 elif command -v grub2-mkconfig &>/dev/null; then - local cfg="/boot/grub2/grub.cfg" - local efi_cfg - efi_cfg="$(ls /boot/efi/EFI/*/grub.cfg 2>/dev/null | head -1 || true)" - [[ -n "${efi_cfg}" ]] && cfg="${efi_cfg}" - grub2-mkconfig -o "${cfg}" + # + # On Fedora/RHEL /boot/efi/EFI/*/grub.cfg is a stub that chainloads + # /boot/grub2/grub.cfg, and grub2-mkconfig refuses to overwrite it. + # Prefer the real config; the EFI path is only it on older layouts. + # + local cfg="" + if [[ -f /boot/grub2/grub.cfg ]]; then + cfg="/boot/grub2/grub.cfg" + else + cfg="$(ls /boot/efi/EFI/*/grub.cfg 2>/dev/null | head -1 || true)" + fi + if [[ -n "${cfg}" ]]; then + grub2-mkconfig -o "${cfg}" || regen_ok=0 + else + regen_ok=0 + fi elif command -v grub-mkconfig &>/dev/null; then - grub-mkconfig -o /boot/grub/grub.cfg + grub-mkconfig -o /boot/grub/grub.cfg || regen_ok=0 else warn "No grub config generator found — regenerate grub.cfg manually" IOMMU_STATUS="needs-grub-regen" return 0 fi + + if (( regen_ok == 0 )); then + warn "Could not regenerate grub.cfg — ${grub_file} is staged but inactive" + warn "Regenerate it yourself, or restore ${grub_file}.cmpunlocker.bak" + IOMMU_STATUS="needs-grub-regen" + return 0 + fi ok "Regenerated GRUB config" + + # + # BLS entries carry their own cmdline, and regenerating grub.cfg does not + # rewrite the ones that already exist — only new kernels would pick the + # parameters up. grubby patches the existing entries. + # + if [[ -d /boot/loader/entries ]] && command -v grubby &>/dev/null; then + if grubby --update-kernel=ALL --args="${IOMMU_PARAMS}"; then + ok "Updated existing boot entries via grubby" + else + warn "grubby could not update existing boot entries — only new kernels get ${IOMMU_PARAMS}" + IOMMU_STATUS="needs-grub-regen" + return 0 + fi + fi IOMMU_STATUS="configured" } -- 2.51.2