feat(anaconda): improve installation process and post-install handling
- Add kernel copy step in %pre to ensure vmlinuz-linux is available for mkinitcpio - Refactor xinitrc post-install log detection to use /tmp/fws-post-chroot.log copied by kickstart - Add success detection based on mkinitcpio and grub-install log markers - Display success screen and poweroff on successful installation, show debug logs on failure - Add load_policy and setstatus stub scripts to suppress SELinux-related Anaconda warnings - Force MBR partition table (--disklabel=msdos) for BIOS boot compatibility - Create standard mkinitcpio preset to replace archiso-specific configuration - Automatically inject lvm2 hook when root is on LVM - Fix GRUB installation to properly extract disk path from lsblk output - Downgrade version to 0.5.3 (development/testing release)
This commit is contained in:
@@ -43,14 +43,23 @@ liveimg --url=file:///run/archiso/bootmnt/fws/x86_64/airootfs.sfs
|
||||
# (répond « oui » au lieu de bloquer sur un disque
|
||||
# non reconnu).
|
||||
# clearpart --all : supprime TOUTES les partitions de TOUS les disques.
|
||||
# --initlabel : réécrit une étiquette de disque neuve (GPT/MBR
|
||||
# selon la plateforme).
|
||||
# --initlabel : réécrit une étiquette de disque neuve.
|
||||
# --disklabel=msdos : force une table MBR (et non GPT). CRUCIAL en BIOS :
|
||||
# en BIOS+GPT, GRUB i386-pc exige une partition « BIOS
|
||||
# Boot » (~1 Mo, type EF02) pour embarquer core.img,
|
||||
# qu'Anaconda NE crée PAS avec « bootloader --disabled
|
||||
# » → « this GPT partition label contains no BIOS Boot
|
||||
# Partition; embedding won't be possible » →
|
||||
# grub-install échoue. En MBR, core.img se loge dans
|
||||
# l'espace post-MBR, aucune partition dédiée requise.
|
||||
# ⚠ Ce choix vise le BIOS (cas VMware actuel). Pour l'UEFI il faudra du GPT
|
||||
# (+ ESP) — à rendre dépendant du firmware (%pre) le jour où on cible l'UEFI.
|
||||
# L'utilisateur garde la main dans le GUI (il peut repasser en manuel), mais le
|
||||
# DÉFAUT est désormais un disque net → réinstall fiable à chaque fois.
|
||||
# ⚠ VM mono-disque : « --all » efface le seul disque, c'est voulu. Sur une
|
||||
# machine multi-disques il faudrait cibler avec « --drives=sda ».
|
||||
zerombr
|
||||
clearpart --all --initlabel
|
||||
clearpart --all --initlabel --disklabel=msdos
|
||||
|
||||
# --- Bootloader : géré à la main en %post ------------------------------------
|
||||
# Anaconda lancerait « grub2-install » / « grub2-mkconfig » (binaires Fedora,
|
||||
@@ -85,6 +94,22 @@ cp -f /etc/resolv.conf "$SYSROOT/etc/resolv.conf" 2>/dev/null || true
|
||||
if [ -f /tmp/fws-desktop ]; then
|
||||
cp -f /tmp/fws-desktop "$SYSROOT/tmp/fws-desktop" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# --- Noyau : archiso RETIRE /boot/vmlinuz-linux du squashfs ------------------
|
||||
# mkarchiso boote le noyau depuis l'ISO et l'EXCLUT de l'airootfs squashfs (gain
|
||||
# de place). Conséquence : le payload LiveOS recopie un rootfs SANS noyau →
|
||||
# « mkinitcpio: /boot/vmlinuz-linux must be readable » puis aucun OS à booter
|
||||
# (« Operating System not found »). On récupère donc le noyau depuis le média
|
||||
# booté (/run/archiso/bootmnt/<install_dir>/boot/<arch>/vmlinuz-linux) et on le
|
||||
# dépose dans la cible. Les modules (/usr/lib/modules) sont, eux, dans le
|
||||
# squashfs → déjà recopiés. Avec le noyau présent, le %post chrooté peut bâtir
|
||||
# l'initramfs (mkinitcpio) et GRUB trouve de quoi booter.
|
||||
SRC_KERN="$(find /run/archiso/bootmnt -name 'vmlinuz-linux' 2>/dev/null | head -1)"
|
||||
if [ -n "$SRC_KERN" ]; then
|
||||
cp -f "$SRC_KERN" "$SYSROOT/boot/vmlinuz-linux"
|
||||
else
|
||||
echo "[FWS] AVERTISSEMENT : noyau vmlinuz-linux introuvable sur le média"
|
||||
fi
|
||||
%end
|
||||
|
||||
|
||||
@@ -113,7 +138,24 @@ if pacman -Q mkinitcpio-archiso &>/dev/null; then
|
||||
pacman -Rns --noconfirm mkinitcpio-archiso || true
|
||||
fi
|
||||
|
||||
# --- 2) initramfs propre (sans le hook « archiso ») --------------------------
|
||||
# --- 2) initramfs propre (preset Arch standard, sans archiso) ----------------
|
||||
# Le live fournit un preset 'archiso' (/etc/mkinitcpio.d/linux.preset qui pointe
|
||||
# vers conf.d/archiso.conf + hooks archiso) → inadapté à un disque normal. On
|
||||
# pose un preset Arch standard (config par défaut /etc/mkinitcpio.conf).
|
||||
cat > /etc/mkinitcpio.d/linux.preset <<'PRESET'
|
||||
ALL_kver="/boot/vmlinuz-linux"
|
||||
PRESETS=('default' 'fallback')
|
||||
default_image="/boot/initramfs-linux.img"
|
||||
fallback_image="/boot/initramfs-linux-fallback.img"
|
||||
fallback_options="-S autodetect"
|
||||
PRESET
|
||||
# Le partitionnement auto d'Anaconda met « / » sur LVM (/dev/mapper/...-root).
|
||||
# Sans le hook 'lvm2' dans l'initramfs, le VG n'est pas activé au boot → la
|
||||
# racine est introuvable → kernel panic. On l'insère avant 'filesystems' s'il
|
||||
# manque (inoffensif si la racine n'est finalement pas sur LVM).
|
||||
if ! grep -qE '^HOOKS=.*\blvm2\b' /etc/mkinitcpio.conf; then
|
||||
sed -i -E 's/^(HOOKS=\(.*)\bfilesystems\b/\1lvm2 filesystems/' /etc/mkinitcpio.conf
|
||||
fi
|
||||
mkinitcpio -P || echo "[FWS] AVERTISSEMENT : mkinitcpio a échoué"
|
||||
|
||||
# --- 3) GRUB installé à la main (cf. bootloader --disabled) ------------------
|
||||
@@ -134,11 +176,14 @@ install_grub() {
|
||||
# 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.)
|
||||
# prend la ligne de type « disk ». ATTENTION : « lsblk -s » dessine un
|
||||
# ARBRE → les caractères de branche (└─) se collent au chemin (on
|
||||
# obtenait disk='-/dev/sda' → « grub-install: cannot find a GRUB drive
|
||||
# for `-/dev/sda' »). On EXTRAIT donc le chemin propre avec grep.
|
||||
local rootsrc disk
|
||||
rootsrc="$(findmnt -no SOURCE / 2>/dev/null)"
|
||||
disk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null | awk '$2=="disk"{print $1; exit}')"
|
||||
disk="$(lsblk -spno NAME,TYPE "$rootsrc" 2>/dev/null \
|
||||
| awk '$2=="disk"{print $1; exit}' | grep -oE '/dev/[a-z0-9]+')"
|
||||
[ -n "$disk" ] || { echo "[FWS] Disque BIOS introuvable pour '$rootsrc'"; return 1; }
|
||||
grub-install --target=i386-pc --recheck "$disk"
|
||||
fi
|
||||
@@ -182,3 +227,18 @@ fi
|
||||
# NetworkManager (activé sur le système installé) régénère /etc/resolv.conf.
|
||||
rm -f /tmp/fws-desktop /etc/resolv.conf 2>/dev/null || true
|
||||
%end
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# %post --nochroot (FINAL) — exfiltre le log du %post chrooté vers le LIVE.
|
||||
# À ce stade la cible est ENCORE montée sous /mnt/sysroot (l'unmount n'a pas
|
||||
# encore eu lieu). On copie /var/log/fws-post.log (résultat de grub-install /
|
||||
# mkinitcpio) vers le live /tmp pour que le harnais de debug (.xinitrc)
|
||||
# l'affiche SANS avoir à remonter le disque démonté — c'est ce log qui dit si
|
||||
# le disque va booter.
|
||||
# ============================================================================
|
||||
%post --nochroot
|
||||
SYSROOT=/mnt/sysroot
|
||||
[ -d "$SYSROOT" ] || SYSROOT=/mnt/sysimage
|
||||
cp -f "$SYSROOT/var/log/fws-post.log" /tmp/fws-post-chroot.log 2>/dev/null || true
|
||||
%end
|
||||
|
||||
Reference in New Issue
Block a user