#!/bin/bash # Script d'installation Automatique Chainloader Gen8 # A copier sur pastebin.com (RAW) echo "=== Gen8 Chainloader Auto-Installer ===" echo "ATTENTION : Ce script va effacer la carte SD/USB cible." # 1. Detection des disques lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE echo "" echo "Identifiez votre carte MicroSD ou clé USB Chainloader (ex: sdb, sdc)." echo "Ne choisissez PAS sda (votre SSD TrueNAS)!" read -p "Entrez le nom du device (ex: sdb) : " DISK DEVICE="/dev/$DISK" if; then echo "Erreur: $DEVICE n'existe pas." exit 1 fi echo "Vous avez choisi : $DEVICE" read -p "Etes-vous sur de vouloir TOUT EFFACER sur $DEVICE? (y/n) " CONFIRM if; then echo "Annulation." exit 0 fi # 2. Preparation Disque echo "[+] Nettoyage et Partitionnement..." umount ${DEVICE}* 2>/dev/null parted -s $DEVICE mklabel msdos parted -s $DEVICE mkpart primary ext2 1MiB 100% parted -s $DEVICE set 1 boot on mdev -s 2>/dev/null # Refresh devices sleep 2 # 3. Formatage echo "[+] Formatage ext2..." mkfs.ext2 ${DEVICE}1 > /dev/null # 4. Montage echo "[+] Montage..." mkdir -p /mnt/chainboot mount ${DEVICE}1 /mnt/chainboot # 5. Installation GRUB echo "[+] Installation GRUB (i386-pc)..." grub-install --target=i386-pc --boot-directory=/mnt/chainboot/boot $DEVICE # 6. Configuration GRUB Dynamique echo "[+] Creation grub.cfg..." cat > /mnt/chainboot/boot/grub/grub.cfg <