Skip to content

Commit 1653fda

Browse files
sashasimkinigorpecovnik
authored andcommitted
apply cryptroot fixes to grub-riscv64 too re. #6280
1 parent 2842de0 commit 1653fda

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

extensions/grub-riscv64.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function extension_prepare_config__prepare_grub-riscv64() {
1515
declare -g IMAGE_PARTITION_TABLE="gpt" # GPT partition table is essential for many UEFI-like implementations, eg Apple+Intel stuff.
1616
declare -g UEFISIZE=256 # in MiB - grub EFI is tiny - but some EFI BIOSes ignore small too small EFI partitions
1717
declare -g BOOTSIZE=0 # No separate /boot when using UEFI.
18+
if [[ $BOOTPART_REQUIRED == "yes" ]]; then
19+
# It is important to place this into /boot to have unified boot partition, especially when CRYPTROOT is used
20+
declare -g UEFI_MOUNT_POINT=/boot
21+
fi
1822
declare -g CLOUD_INIT_CONFIG_LOCATION="${CLOUD_INIT_CONFIG_LOCATION:-/boot/efi}" # use /boot/efi for cloud-init as default when using Grub.
1923
declare -g EXTRA_BSP_NAME="${EXTRA_BSP_NAME}-grub" # Unique bsp name.
2024
declare -g UEFI_GRUB_TARGET="riscv64-efi" # Default for x86_64
@@ -55,14 +59,19 @@ pre_umount_final_image__install_grub() {
5559
# Irony: let's use grub-probe to find out the UUID of the root partition, and then create a symlink to it.
5660
# Another: on some systems (eg, not Docker) the thing might already exist due to udev actually working.
5761
# shellcheck disable=SC2016 # some wierd escaping going on there.
62+
# Root is needed so that UUID of the unlocked /dev/mapper/armbian-root is discovered by grub-update,
63+
# UUID is then put into grub.cfg instead of raw /dev/mapper/armbian-root which will fail further sanity check
5864
chroot_custom "$chroot_target" mkdir -pv '/dev/disk/by-uuid/"$(grub-probe --target=fs_uuid /)"' "||" true
65+
# Include /boot that might point to a separate boot partition in case one exists (lvm, cryptroot)
66+
# Even if boot partition doesn't exist - the command will be the same as mkdir for / above
67+
chroot_custom "$chroot_target" mkdir -pv '/dev/disk/by-uuid/"$(grub-probe --target=fs_uuid /boot)"' "||" true
5968

6069
display_alert "Extension: ${EXTENSION}: Creating GRUB config..." "${EXTENSION}: grub-mkconfig / update-grub"
6170
chroot_custom "$chroot_target" update-grub || {
6271
exit_with_error "update-grub failed!"
6372
}
6473

65-
local install_grub_cmdline="grub-install --target=${UEFI_GRUB_TARGET} --no-nvram --removable" # nvram is global to the host, even across chroot. take care.
74+
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.
6675
display_alert "Extension: ${EXTENSION}: Installing GRUB EFI..." "${EXTENSION}: ${UEFI_GRUB_TARGET}"
6776
chroot_custom "$chroot_target" "$install_grub_cmdline" || {
6877
exit_with_error "Extension: ${EXTENSION}: ${install_grub_cmdline} failed!"
@@ -124,8 +133,11 @@ configure_grub() {
124133
GRUB_TIMEOUT_STYLE=menu # Show the menu with Kernel options (Armbian or -generic)...
125134
GRUB_TIMEOUT=${UEFI_GRUB_TIMEOUT} # ... for ${UEFI_GRUB_TIMEOUT} seconds, then boot the Armbian default.
126135
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)
136+
GRUB_DISABLE_OS_PROBER=false # Have to be explicit about enabling os-prober
127137
GRUB_GFXMODE=1024x768
128138
GRUB_GFXPAYLOAD=keep
139+
GRUB_DISABLE_UUID=false # Be explicit about wanting UUID
140+
GRUB_DISABLE_LINUX_UUID=false # Be explicit about wanting UUID
129141
grubCfgFrag
130142

131143
if [[ "a${UEFI_GRUB_DISABLE_OS_PROBER}" != "a" ]]; then

0 commit comments

Comments
 (0)