From 1653fdacecfd8ea19a6324fabdffcb70ee7da92c Mon Sep 17 00:00:00 2001 From: Alex Simkin Date: Fri, 31 Oct 2025 20:56:36 +0200 Subject: [PATCH] apply cryptroot fixes to grub-riscv64 too re. #6280 --- extensions/grub-riscv64.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/grub-riscv64.sh b/extensions/grub-riscv64.sh index 8455c83ac..b665291eb 100644 --- a/extensions/grub-riscv64.sh +++ b/extensions/grub-riscv64.sh @@ -15,6 +15,10 @@ function extension_prepare_config__prepare_grub-riscv64() { declare -g IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff. declare -g UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions declare -g BOOTSIZE=0 # No separate /boot when using UEFI. + if [[ $BOOTPART_REQUIRED == "yes" ]]; then + # It is important to place this into /boot to have unified boot partition, especially when CRYPTROOT is used + declare -g UEFI_MOUNT_POINT=/boot + fi declare -g CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub. declare -g EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name. declare -g UEFI_GRUB_TARGET="riscv64-efi" # Default for x86_64 @@ -55,14 +59,19 @@ pre_umount_final_image__install_grub() { # Irony: let's use grub-probe to find out the UUID of the root partition, and then create a symlink to it. # Another: on some systems (eg, not Docker) the thing might already exist due to udev actually working. # shellcheck disable=SC2016 # some wierd escaping going on there. + # Root is needed so that UUID of the unlocked /dev/mapper/armbian-root is discovered by grub-update, + # UUID is then put into grub.cfg instead of raw /dev/mapper/armbian-root which will fail further sanity check chroot_custom "$chroot_target" mkdir -pv '/dev/disk/by-uuid/"$(grub-probe --target=fs_uuid /)"' "||" true + # Include /boot that might point to a separate boot partition in case one exists (lvm, cryptroot) + # Even if boot partition doesn't exist - the command will be the same as mkdir for / above + chroot_custom "$chroot_target" mkdir -pv '/dev/disk/by-uuid/"$(grub-probe --target=fs_uuid /boot)"' "||" true display_alert "Extension: ${EXTENSION}: Creating GRUB config..." "${EXTENSION}: grub-mkconfig / update-grub" chroot_custom "$chroot_target" update-grub || { exit_with_error "update-grub failed!" } - local install_grub_cmdline="grub-install --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care. + local install_grub_cmdline="grub-install --target=${UEFI_GRUB_TARGET} --efi-directory=${UEFI_MOUNT_POINT} --no-nvram --removable" # nvram is global to the host, even across chroot. take care. display_alert "Extension: ${EXTENSION}: Installing GRUB EFI..." "${EXTENSION}: ${UEFI_GRUB_TARGET}" chroot_custom "$chroot_target" "$install_grub_cmdline" || { exit_with_error "Extension: ${EXTENSION}: ${install_grub_cmdline} failed!" @@ -124,8 +133,11 @@ configure_grub() { GRUB_TIMEOUT_STYLE=menu # Show the menu with Kernel options (Armbian or -generic)... GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT} # ... for ${UEFI_GRUB_TIMEOUT} seconds, then boot the Armbian default. GRUB_DISTRIBUTOR="${UEFI_GRUB_DISTRO_NAME}" # On GRUB menu will show up as "Armbian GNU/Linux" (will show up in some UEFI BIOS boot menu (F8?) as "armbian", not on others) + GRUB_DISABLE_OS_PROBER=false # Have to be explicit about enabling os-prober GRUB_GFXMODE=1024x768 GRUB_GFXPAYLOAD=keep + GRUB_DISABLE_UUID=false # Be explicit about wanting UUID + GRUB_DISABLE_LINUX_UUID=false # Be explicit about wanting UUID grubCfgFrag if [[ "a${UEFI_GRUB_DISABLE_OS_PROBER}" != "a" ]]; then