fix reinstall GRUB to run reinstall automaticly when all is mounted

This commit is contained in:
2025-07-08 10:51:12 +02:00
parent eff6f92c28
commit 4c56b05a2f
+16 -22
View File
@@ -1,51 +1,45 @@
#!/bin/bash #!/bin/bash
set -e
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "Bitte geben sie ihre luks partition an" echo "Bitte geben Sie Ihre LUKS-Partition an"
exit 1 exit 1
fi fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
echo "Bitte geben den Name für ihre Root BTRFS SubVolumen an" echo "Bitte geben Sie den Namen für Ihr Root-BTRFS-Subvolumen an"
exit 1 exit 1
fi fi
if [ -z "$3" ]; then if [ -z "$3" ]; then
echo "Bitte geben sie ihre EFI partition an" echo "Bitte geben Sie Ihre EFI-Partition an"
exit 1 exit 1
fi fi
# Stelle sicher, dass das System als root ausgeführt wird # Stelle sicher, dass das Skript als root läuft
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then
echo "Dieses Skript muss als root ausgeführt werden" 1>&2 echo "Dieses Skript muss als root ausgeführt werden"
exit 1 exit 1
fi fi
# Stelle sicher, dass das manjaro-system-tool installiert ist # LUKS öffnen
pacman -S manjaro-system-tools --noconfirm
# Öffne die verschlüsselte LUKS-Partition
cryptsetup luksOpen "$1" luks cryptsetup luksOpen "$1" luks
# Mounte das BTRFS-Dateisystem # Root-Subvolumen mounten
mount -t btrfs -o subvol="$2" /dev/mapper/luks /mnt mount -t btrfs -o subvol="$2" /dev/mapper/luks /mnt
# Mounte die EFI-Partition # EFI mounten
mount "$3" /mnt/boot/efi mount "$3" /mnt/boot/efi
# Wechsle in das gemountete Dateisystem # chroot-Befehle ausführen
manjaro-chroot /mnt manjaro-chroot /mnt bash -c "
# Installiere den GRUB-Bootloader neu
grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg
"
# Beende die manjaro-chroot-Umgebung # Unmount und Aufräumen
exit umount -R /mnt/boot/efi
umount -R /mnt
# Schließe die LUKS-Partition # Schließe die LUKS-Partition
cryptsetup luksClose luks cryptsetup luksClose luks
# Entferne das gemountete Dateisystem echo 'GRUB wurde erfolgreich neu installiert.'
umount /mnt/boot/efi
umount /mnt
echo "GRUB wurde erfolgreich neu installiert."