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.
This commit is contained in:
@@ -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
|
# 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
|
# 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é).
|
# 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
|
DBG=/tmp/fws-debug.txt
|
||||||
{
|
{
|
||||||
echo "===== liveinst sorti (code $rc) — logs Anaconda ====="
|
echo "===== liveinst sorti (code $rc) — logs Anaconda ====="
|
||||||
echo
|
echo
|
||||||
echo "########## sortie liveinst (stdout+stderr) ##########"
|
echo "########## sortie liveinst (stdout+stderr) ##########"
|
||||||
cat "$LIVEINST_LOG" 2>/dev/null
|
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 \
|
for f in /tmp/anaconda.log /tmp/syslog /tmp/program.log \
|
||||||
/tmp/storage.log /tmp/dbus.log /tmp/packaging.log /tmp/X.log; do
|
/tmp/storage.log /tmp/dbus.log /tmp/packaging.log /tmp/X.log; do
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -119,16 +119,28 @@ mkinitcpio -P || echo "[FWS] AVERTISSEMENT : mkinitcpio a échoué"
|
|||||||
# --- 3) GRUB installé à la main (cf. bootloader --disabled) ------------------
|
# --- 3) GRUB installé à la main (cf. bootloader --disabled) ------------------
|
||||||
install_grub() {
|
install_grub() {
|
||||||
if [ -d /sys/firmware/efi ]; then
|
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
|
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 \
|
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
|
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
|
local rootsrc disk
|
||||||
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
|
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
|
||||||
disk="$(lsblk -no pkname "$rootsrc" 2>/dev/null | head -1)"
|
disk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null | awk '$2=="disk"{print $1; exit}')"
|
||||||
[ -n "$disk" ] || { echo "[FWS] Disque BIOS introuvable"; return 1; }
|
[ -n "$disk" ] || { echo "[FWS] Disque BIOS introuvable pour '$rootsrc'"; return 1; }
|
||||||
grub-install --target=i386-pc --recheck "/dev/$disk"
|
grub-install --target=i386-pc --recheck "$disk"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
if install_grub; then
|
if install_grub; then
|
||||||
|
|||||||
Reference in New Issue
Block a user