From 9e3cca8efc82ed592cb333ec3aeb1e2e8f8d99a8 Mon Sep 17 00:00:00 2001 From: nocode Date: Fri, 19 Jun 2026 15:44:18 +0200 Subject: [PATCH] fix(installer): improve bootloader installation and debug logging - Add fallback GRUB installation for UEFI systems using --removable flag to ensure boot without NVRAM entries - Fix BIOS disk detection for LVM root partitions by using lsblk with proper filtering instead of pkname - Enhance debug logging to include %post chroot phase logs (fws-post.log) which indicate bootloader success - Automatically mount and retrieve installation logs from the installed disk to verify bootloader installation - Add detailed comments explaining UEFI/BIOS fallback strategies and LVM-aware disk detection These changes ensure the system can boot even when NVRAM entries are missing or forgotten by firmware, and provide better visibility into bootloader installation success during the debug phase. --- configs/baseline/airootfs/root/.xinitrc | 29 +++++++++++++++++++ .../share/anaconda/interactive-defaults.ks | 22 ++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/configs/baseline/airootfs/root/.xinitrc b/configs/baseline/airootfs/root/.xinitrc index c71d957..914da48 100644 --- a/configs/baseline/airootfs/root/.xinitrc +++ b/configs/baseline/airootfs/root/.xinitrc @@ -29,12 +29,41 @@ if command -v liveinst >/dev/null 2>&1; then # planté. On ne se fie donc PAS à $rc : en phase debug on regroupe TOUS les # logs et on les affiche systématiquement (zenity). Le traceback Python d'un # crash d'import précoce n'est QUE dans $LIVEINST_LOG (stderr capturé). + # Le %post chrooté (grub-install / mkinitcpio = ce qui rend le disque + # BOOTABLE) écrit /var/log/fws-post.log SUR LE DISQUE INSTALLÉ, qu'Anaconda + # a démonté. On réactive le LVM et on remonte (lecture seule) le 1er système + # qui contient ce log : c'est LUI qui dit si le bootloader a bien été posé. + FWS_POST="" + vgchange -ay >/dev/null 2>&1 || true + udevadm settle --timeout=10 >/dev/null 2>&1 || true + mkdir -p /run/fws-installed + for _dev in /dev/mapper/*-root /dev/mapper/* /dev/sd*[0-9] /dev/vd*[0-9] /dev/nvme*n*p*; do + [ -b "$_dev" ] || continue + mount -o ro "$_dev" /run/fws-installed 2>/dev/null || continue + if [ -f /run/fws-installed/var/log/fws-post.log ]; then + FWS_POST=/run/fws-installed/var/log/fws-post.log + break + fi + umount /run/fws-installed 2>/dev/null || true + done + DBG=/tmp/fws-debug.txt { echo "===== liveinst sorti (code $rc) — logs Anaconda =====" echo echo "########## sortie liveinst (stdout+stderr) ##########" cat "$LIVEINST_LOG" 2>/dev/null + echo + echo "########## %post chrooté = grub-install / mkinitcpio (/var/log/fws-post.log) ##########" + echo "########## >>> C'EST CE BLOC QUI DIT SI LE DISQUE VA BOOTER <<< ##########" + if [ -n "$FWS_POST" ]; then + cat "$FWS_POST" 2>/dev/null + else + echo "(log introuvable — disque installé non remonté)" + fi + echo + echo "########## %post --nochroot (/tmp/fws-post-nochroot.log) ##########" + cat /tmp/fws-post-nochroot.log 2>/dev/null || echo "(absent)" for f in /tmp/anaconda.log /tmp/syslog /tmp/program.log \ /tmp/storage.log /tmp/dbus.log /tmp/packaging.log /tmp/X.log; do echo diff --git a/configs/releng/airootfs/usr/share/anaconda/interactive-defaults.ks b/configs/releng/airootfs/usr/share/anaconda/interactive-defaults.ks index faac33d..1b8400d 100644 --- a/configs/releng/airootfs/usr/share/anaconda/interactive-defaults.ks +++ b/configs/releng/airootfs/usr/share/anaconda/interactive-defaults.ks @@ -119,16 +119,28 @@ mkinitcpio -P || echo "[FWS] AVERTISSEMENT : mkinitcpio a échoué" # --- 3) GRUB installé à la main (cf. bootloader --disabled) ------------------ install_grub() { if [ -d /sys/firmware/efi ]; then + # UEFI. efibootmgr crée l'entrée NVRAM « FWS », mais il peut MANQUER de + # l'airootfs et son install dépend du réseau → on ne BLOQUE pas dessus. pacman -Q efibootmgr &>/dev/null || pacman -Sy --noconfirm efibootmgr || true + # (a) Entrée NVRAM dédiée (best effort, si efibootmgr dispo) : grub-install --target=x86_64-efi --efi-directory=/boot/efi \ - --bootloader-id=FWS --recheck + --bootloader-id=FWS --recheck || true + # (b) Chemin de SECOURS EFI/BOOT/BOOTX64.EFI (--removable) : boote SANS + # aucune entrée NVRAM. INDISPENSABLE en VM / sans réseau / firmware + # qui « oublie » l'entrée — c'est lui qui garantit le 1er boot UEFI. + grub-install --target=x86_64-efi --efi-directory=/boot/efi \ + --bootloader-id=FWS --removable --recheck else - # BIOS : retrouver le disque physique portant « / ». + # BIOS : installer GRUB dans le MBR du DISQUE physique (PAS une partition) + # portant « / », même quand « / » est sur du LVM (chaîne + # LV → PV partition → disque). « lsblk -s » descend vers le physique ; on + # prend la 1re ligne de type « disk ». (L'ancien « lsblk -no pkname » + # renvoyait la PARTITION sda2 → grub-install échouait sur un root LVM.) local rootsrc disk rootsrc="$(findmnt -no SOURCE / 2>/dev/null)" - disk="$(lsblk -no pkname "$rootsrc" 2>/dev/null | head -1)" - [ -n "$disk" ] || { echo "[FWS] Disque BIOS introuvable"; return 1; } - grub-install --target=i386-pc --recheck "/dev/$disk" + disk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null | awk '$2=="disk"{print $1; exit}')" + [ -n "$disk" ] || { echo "[FWS] Disque BIOS introuvable pour '$rootsrc'"; return 1; } + grub-install --target=i386-pc --recheck "$disk" fi } if install_grub; then