From 11f708b4739ca2b8858247e53a948f0559eb609f Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 29 Oct 2021 12:23:21 -0400 Subject: [PATCH] grub: support searching for boot by UUID This adds support for a `bootuuid.cfg` dropin sitting alongside both the BIOS and EFI GRUB configs to specify the UUID to scan for instead of relying on labels. Part of https://github.com/coreos/fedora-coreos-tracker/issues/976. --- src/create_disk.sh | 9 ++++++++- src/grub.cfg | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/create_disk.sh b/src/create_disk.sh index 14339c3144..7d7117e857 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -339,7 +339,14 @@ if [ -e (md/md-boot) ]; then # the main grub.cfg. set prefix=md/md-boot else - search --label boot --set prefix --no-floppy + if [ -f ${config_directory}/bootuuid.cfg ]; then + source ${config_directory}/bootuuid.cfg + fi + if [ -n "${BOOT_UUID}" ]; then + search --fs-uuid "${BOOT_UUID}" --set prefix --no-floppy + else + search --label boot --set prefix --no-floppy + fi fi set prefix=($prefix)/grub2 configfile $prefix/grub.cfg diff --git a/src/grub.cfg b/src/grub.cfg index 48171f07b7..f213ff97cd 100644 --- a/src/grub.cfg +++ b/src/grub.cfg @@ -19,7 +19,14 @@ if [ -d (md/md-boot)/grub2 ]; then set boot=md/md-boot set prefix=($boot)/grub2 else - search --label boot --set boot --no-floppy + if [ -f ${config_directory}/bootuuid.cfg ]; then + source ${config_directory}/bootuuid.cfg + fi + if [ -n "${BOOT_UUID}" ]; then + search --fs-uuid "${BOOT_UUID}" --set boot --no-floppy + else + search --label boot --set boot --no-floppy + fi fi set root=$boot