From dd0b95dbde68e24f3e01f45f820f7b806fe8df43 Mon Sep 17 00:00:00 2001 From: Jax Jiang Date: Fri, 11 Feb 2022 01:46:55 +0800 Subject: [PATCH] x86: grub2: search for the "kernel" filesystem on all disks Previously, grub2 was hardcoded to always look on "hd0" for the kernel. This works well when the system only had a single disk. But if there was a second disk/stick present, it may have look on the wrong drive because of enumeration races. This patch utilizes grub2 search function to look for a filesystem with the label "kernel". This works thanks to existing setup in scripts/gen_image_generic.sh. Which sets the "kernel" label on both the fat and ext4 filesystem variants. Signed-off-by: Jax Jiang Suggested-by: Alberto Bursi (MX100 WA) (word wrapped, slightly rewritten commit message, removed MX100 WA) Signed-off-by: Christian Lamparter --- package/boot/grub2/Makefile | 8 ++++---- target/linux/x86/image/grub-efi.cfg | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package/boot/grub2/Makefile b/package/boot/grub2/Makefile index be1cb128e..a6b79f2ad 100644 --- a/package/boot/grub2/Makefile +++ b/package/boot/grub2/Makefile @@ -105,28 +105,28 @@ define Package/grub2/install -O i386-pc \ -c $(PKG_BUILD_DIR)/grub-early.cfg \ -o $(STAGING_DIR_IMAGE)/grub2/gpt-core.img \ - at_keyboard biosdisk boot chain configfile fat linux ls part_gpt reboot serial vga + at_keyboard biosdisk boot chain configfile fat linux ls part_gpt reboot search serial vga $(STAGING_DIR_HOST)/bin/grub-mkimage \ -d $(PKG_BUILD_DIR)/grub-core \ -p /boot/grub \ -O i386-pc \ -c ./files/grub-early.cfg \ -o $(STAGING_DIR_IMAGE)/grub2/generic-core.img \ - at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga + at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot search serial vga $(STAGING_DIR_HOST)/bin/grub-mkimage \ -d $(PKG_BUILD_DIR)/grub-core \ -p /boot/grub \ -O i386-pc \ -c ./files/grub-early.cfg \ -o $(STAGING_DIR_IMAGE)/grub2/eltorito.img \ - at_keyboard biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial test vga + at_keyboard biosdisk boot chain configfile iso9660 linux ls part_msdos reboot search serial test vga $(STAGING_DIR_HOST)/bin/grub-mkimage \ -d $(PKG_BUILD_DIR)/grub-core \ -p /boot/grub \ -O i386-pc \ -c ./files/grub-early.cfg \ -o $(STAGING_DIR_IMAGE)/grub2/legacy-core.img \ - biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga + biosdisk boot chain configfile ext2 linux ls part_msdos reboot search serial vga endef define Package/grub2-efi/install diff --git a/target/linux/x86/image/grub-efi.cfg b/target/linux/x86/image/grub-efi.cfg index 14d30e88e..bbb31f774 100644 --- a/target/linux/x86/image/grub-efi.cfg +++ b/target/linux/x86/image/grub-efi.cfg @@ -3,7 +3,7 @@ set default="0" set timeout="@TIMEOUT@" -set root='(hd0,gpt1)' +search -l kernel -s root menuentry "@TITLE@" { linux /boot/vmlinuz @GPT_ROOTPART@ @CMDLINE@ noinitrd