Browse Source

added condition to install grub-efi

Toastie 6 months ago
parent
commit
e09b27fa19
1 changed files with 17 additions and 6 deletions
  1. 17 6
      bootstrap-bookworm.sh

+ 17 - 6
bootstrap-bookworm.sh

@@ -7,7 +7,7 @@
 # - One disk, one partion, swap-file in the same partion as safety net
 # - Use systemd whereever possible (network, ntp, cron, journald logging)
 # - Minimal number of packages & cloud kernel
-# - grub-pc, not efi
+# - support for grub-pc and grub-efi
 # - random root and admin user password generation
 # - ssh on port 50101 limited to the admin user
 
@@ -25,9 +25,9 @@
 # sudo /installer/bootstrap-bullseye.sh postinstall  # run postinstall in the new system
 
 # Variables
-mnt="/mnt/root"  # mountpoint for the new root filesystem
+mnt="/mnt/root"  # mountpoint for the root filesystem during installation
 hostname="somehost.example.com"
-partition="single-mbr"
+partition="mbr-single"
 disk="/dev/vda"  # lsblk --list
 disk1=$disk"1"
 disk0=$disk"p1"  # efi partion, only relevant if partion="efi"
@@ -55,7 +55,7 @@ echo nameserver $netDNS2 >> /etc/resolv.conf
 
 install(){
 
-if [ "$partition" = "single-mbr" ]
+if [ "$partition" = "mbr-single" ]
 then
   #----------
   # Prepare disks
@@ -240,8 +240,19 @@ exit
 
 
 bootloader(){
-# Install GRUB in /dev/vba
-chroot $mnt /bin/bash -c "grub-install $disk && update-grub"
+
+# Install grub in the mbr
+if [ $partition="mbr-single" ]
+then
+  chroot $mnt /bin/bash -c "grub-install $disk && update-grub"
+fi
+
+# Install grub in the efi partition
+if [ $partition="efi-crypt" ]
+then
+  chroot $mnt /bin/bash -c \
+  "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub && update-grub" 
+fi
 }
 
 unmount(){