Fix unbootable installs: lay the kernel into the target and own GRUB

archiso keeps vmlinuz/initramfs in the ISO boot dir, not the squashfs, so
unpackfs lays down an empty /boot. The chroot's mkinitcpio/grub-mkconfig had
nothing to work with and the ESP ended up empty (firmware found no bootloader).

- shellprocess@kernel (dontChroot) copies the live kernel into the target
  /boot before the bootloader step
- post-install.sh now runs grub-install itself, including a --removable pass
  so firmware with no NVRAM entry still boots via EFI/BOOT/BOOTX64.EFI
This commit is contained in:
Breadway 2026-06-14 17:57:50 +08:00
parent 2116b7cd7b
commit 078c5f4f94
5 changed files with 61 additions and 1 deletions

View file

@ -35,7 +35,26 @@ fallback_options="-S autodetect"
PRESET
mkinitcpio -P || echo "WARN: mkinitcpio regeneration failed"
# Refresh GRUB so it references the rebuilt initramfs (and the new fallback).
# ---------------------------------------------------------------------------
# Install GRUB ourselves. Calamares' bootloader module runs before the kernel
# and initramfs exist (archiso keeps them out of the squashfs; shellprocess
# @kernel only lays vmlinuz down just beforehand), so its grub-install/config
# leaves the ESP empty. Redo it here, now that /boot is fully populated.
#
# Two passes: the standard NVRAM entry, plus a --removable copy to
# EFI/BOOT/BOOTX64.EFI so firmware that lost/never wrote an NVRAM entry (the
# "no boot device / screen just refreshes" failure) still finds a bootloader.
# ---------------------------------------------------------------------------
if command -v grub-install &>/dev/null; then
grub-install --target=x86_64-efi --efi-directory=/boot/efi \
--bootloader-id=BOS --recheck \
|| echo "WARN: grub-install (nvram) failed"
grub-install --target=x86_64-efi --efi-directory=/boot/efi \
--removable --recheck \
|| echo "WARN: grub-install (removable) failed"
fi
# Refresh GRUB so it references the kernel + rebuilt initramfs.
if command -v grub-mkconfig &>/dev/null; then
grub-mkconfig -o /boot/grub/grub.cfg || echo "WARN: grub-mkconfig failed"
fi