@@ -345,16 +345,25 @@ for dir in /dev /proc /sys; do
345345done
346346
347347#
348- # Mount /boot/efi and do grub and bootctl install
348+ # Mount ESP and bootctl install
349349#
350- EFI_DIR=" /mnt/boot/efi"
351- chroot " $DIRECTORY " mkdir -p $EFI_DIR
352- chroot " $DIRECTORY " mount /dev/mapper/${LOOPNAME} p2 $EFI_DIR
350+ EFI_DIR=$( chroot " $DIRECTORY " mktemp -d -p " /var/tmp/" -t delphix_efi.XXXXXXX)
351+ chroot " $DIRECTORY " mount -o umask=077 /dev/mapper/${LOOPNAME} p2 $EFI_DIR
352+
353+ ESP=$EFI_DIR
354+ BOOTLOADER_ID=" ${BOOTLOADER_ID:- systemd} "
355+ echo " [*] Installing systemd-boot to $ESP ..."
356+ # 1. Create required directories
357+ chroot " $DIRECTORY " mkdir -p " $ESP /EFI/systemd" " $ESP /EFI/BOOT" " $ESP /loader/entries"
358+
359+ # 2. Copy systemd-boot binaries
360+ chroot " $DIRECTORY " cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi " $ESP /EFI/$BOOTLOADER_ID /"
361+ chroot " $DIRECTORY " cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi " $ESP /EFI/BOOT/BOOTX64.EFI"
353362
354363# Copy the latest kernel into EFI boot directory
355364chroot " $DIRECTORY " cp /boot/initrd.img $EFI_DIR
356365chroot " $DIRECTORY " cp /boot/vmlinuz $EFI_DIR
357- chroot " $DIRECTORY " bootctl --esp-path=$EFI_DIR install --no-variables
366+ # chroot "$DIRECTORY" bootctl --esp-path=$EFI_DIR install --no-variables
358367
359368# Use GRUB_CMDLINE_LINUX_DEFAULT boot options
360369source $DIRECTORY /etc/default/grub.d/override.cfg
@@ -385,6 +394,7 @@ auto-firmware yes
385394EOF
386395
387396chroot " $DIRECTORY " umount $EFI_DIR
397+ chroot " $DIRECTORY " rm -r $EFI_DIR
388398
389399for dir in /dev /proc /sys; do
390400 retry 5 10 umount -R " ${DIRECTORY}${dir} "
0 commit comments