fix(installer): find the EFI system partition instead of never finding it

Both the kickstart %post and fws-grub-finalize looked for the ESP with

    lsblk -nro PATH,PARTTYPENAME,FSTYPE | awk '$2=="EFI System" && $3=="vfat"'

but "lsblk -r" separates columns with SPACES and an ESP's label is literally
"EFI System" -- with a space. awk therefore sees $2="EFI" and $3="System", so
the condition can never be true and no ESP was ever found. The consequences
chain: /boot/efi never mounted, install_grub returns 1, grub-install and
grub-mkconfig skipped, /boot/grub missing, and the step 4ter grub-mkconfig
fails in turn (visible in the 2026-09-06 install journal as "+ grub-mkconfig"
followed by "+ true"). This is why GRUB had to be repaired by hand in a TTY
after bare-metal installs -- the first-boot safety net carried the same bug.

Detection now reads PARTTYPE (a type CODE: GUID on GPT, 0xef on MBR, never a
space) and queries each vfat partition separately, so an empty column cannot
shift the fields either.

Also in this commit:
- /boot/grub is created before any grub-mkconfig, so the menu is generated even
  when grub-install failed.
- The step 4ter grub-mkconfig no longer swallows its stderr; a failure now
  lands in /var/log/fws-post.log instead of /dev/null.
- clearpart no longer forces --disklabel=msdos: the table type is left to
  Anaconda/blivet, which picks it from the firmware (BIOS -> msdos, UEFI ->
  gpt). Forcing MBR under UEFI is out of spec and makes dual-boot beside a
  GPT Windows impossible.
- The resolv.conf copy to the target removes the destination first and copies
  the CONTENT, since /etc/resolv.conf is now a symlink on both sides.

Signed-off-by: nocode <suzuku295@gmail.com>
This commit is contained in:
nocode committed 2026-09-09 10:08:02 +02:00
1 parent 9cd772817c
commit c7ac8a68d8
2 files changed
+98 -20

No files matched your search

@@ -51,6 +51,29 @@ else
echo "[FWS] os-prober indisponible — Windows ne sera pas détecté au menu GRUB"
fi
# Première partition ESP (vfat + type de partition EFI), optionnellement
# limitée à un disque donné.
#
# ⚠ NE PAS revenir à « lsblk -nro PATH,PARTTYPENAME,FSTYPE | awk '$2=="EFI
# System" …' » : « lsblk -r » sépare les colonnes par des ESPACES et le
# libellé d'une ESP est littéralement « EFI System » — avec une espace. awk
# voyait $2="EFI" et $3="System", le test n'était JAMAIS vrai, aucune ESP
# n'était trouvée et GRUB n'était donc jamais posé en UEFI (ni ici, ni dans
# le %post du kickstart qui portait le même bug).
# On lit PARTTYPE (un CODE : GUID en GPT, 0xef en MBR — jamais d'espace) et on
# interroge chaque partition séparément : une valeur par appel, donc aucun
# décalage de colonnes même si un champ est vide.
find_esp() {
_disk="${1:-}"
lsblk -nrpo NAME,FSTYPE $_disk 2>/dev/null | awk '$2=="vfat"{print $1}' \
| while read -r _part; do
_ptype="$(lsblk -nrdo PARTTYPE "$_part" 2>/dev/null | tr 'A-Z' 'a-z')"
case "$_ptype" in
c12a7328-f81f-11d2-ba4b-00a0c93ec93b|0xef) printf '%s\n' "$_part" ;;
esac
done | head -n1
}
# --- UEFI : installer GRUB sur une ESP ---------------------------------------
# Règle : on préfère une ESP PORTÉE PAR LE MÊME DISQUE que « / » (installation
# FWS typique : /boot/efi déjà dans le fstab). Si l'installation a réutilisé
@@ -64,13 +87,10 @@ if [ -d /sys/firmware/efi ]; then
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
rootdisk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null | awk '$2=="disk"{print $1; exit}')"
if [ -n "$rootdisk" ]; then
esp="$(lsblk -nro PATH,PARTTYPENAME,FSTYPE "$rootdisk" 2>/dev/null \
| awk '$2=="EFI System" && $3=="vfat" {print $1; exit}')"
esp="$(find_esp "$rootdisk")"
fi
# Repli : première ESP du système (ex. ESP Windows réutilisée).
[ -n "$esp" ] || \
esp="$(lsblk -nro PATH,PARTTYPENAME,FSTYPE 2>/dev/null \
| awk '$2=="EFI System" && $3=="vfat" {print $1; exit}')"
[ -n "$esp" ] || esp="$(find_esp)"
if [ -n "$esp" ]; then
echo "[FWS] ESP : $esp → montage sur /boot/efi (ne pas démonter, reboot ensuite)"
mkdir -p /boot/efi