grub2: Specify boot partition
PATCH v2 1/1 grub2: Specify boot partition
Since boot partition was not specified, grub tools try to detect it automatically. This patch add an option to force it.
---
Notice I am not sure -p option is usefull when -c option is used.
v1 -> v2:
* Rewrite help for BR2_TARGET_GRUB2_BOOT_PARTITION option
* Don't show BR2_TARGET_GRUB2_BOOT_PARTITION if EFI is selected
* Rewrite log message
boot/grub2/Config.in | 13 +++++++++++++ boot/grub2/grub2.mk | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
boot/grub2/Config.in +13 -0
@@ -111,6 +111,19 @@ config BR2_TARGET_GRUB2_X86_64_EFI endchoice +if BR2_TARGET_GRUB2_I386_PC + +config BR2_TARGET_GRUB2_BOOT_PARTITION + string "boot partition" + default "(hd0,msdos1)" + help + Specify the partition where the /boot/grub/grub.cfg is located. + Use (hd0,msdos1) for the first partition of the first disk if + using a legacy partition table, or (hd0,gpt1) if using GPT + partition table. + +endif # BR2_TARGET_GRUB2_I386_PC + config BR2_TARGET_GRUB2_BUILTIN_MODULES string "builtin modules" default "boot linux ext2 fat part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC
boot/grub2/grub2.mk +6 -4
@@ -11,9 +11,14 @@ GRUB2_LICENSE = GPLv3+ GRUB2_LICENSE_FILES = COPYING GRUB2_DEPENDENCIES = host-bison host-flex +GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) +GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) +GRUB2_BOOT_PARTITION = $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION)) + ifeq ($(BR2_TARGET_GRUB2_I386_PC),y) GRUB2_IMAGE = $(BINARIES_DIR)/grub.img GRUB2_CFG = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX = $(GRUB2_BOOT_PARTITION)/boot/grub GRUB2_TUPLE = i386-pc GRUB2_TARGET = i386 GRUB2_PLATFORM = pc
@@ -33,9 +38,6 @@ GRUB2_TARGET = x86_64 GRUB2_PLATFORM = efi endif -GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) -GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) - # Grub2 is kind of special: it considers CC, LD and so on to be the # tools to build the native tools (i.e to be executed on the build # machine), and uses TARGET_CC, TARGET_CFLAGS, TARGET_CPPFLAGS to
@@ -71,7 +73,7 @@ define GRUB2_IMAGE_INSTALLATION -d $(HOST_DIR)/usr/lib/grub/$(GRUB2_TUPLE) \ -O $(GRUB2_TUPLE) \ -o $(GRUB2_IMAGE) \ - $(if $(GRUB2_PREFIX),-p $(GRUB2_PREFIX)) \ + -p "$(GRUB2_PREFIX)" \ $(if $(GRUB2_BUILTIN_CONFIG),-c $(GRUB2_BUILTIN_CONFIG)) \ $(GRUB2_BUILTIN_MODULES) mkdir -p $(dir $(GRUB2_CFG))
Signature · 1 line
2.0.0
PATCH v2 1/1 grub2: Specify boot partition
Dear J?r?me Pouiller,
Quoted 4 lines · J?r?me Pouiller
Since boot partition was not specified, grub tools try to detect it automatically. This patch add an option to force it.
Signed-off-by J?r?me Pouiller <[email protected]>
Thanks, it works here. However, I have one suggestion below.
boot/grub2/Config.in config BR2_TARGET_GRUB2_X86_64_EFI · line 123
Quoted 8 lines
boot/grub2/Config.in +8
-0+config BR2_TARGET_GRUB2_BOOT_PARTITION + string "boot partition" + default "(hd0,msdos1)" + help + Specify the partition where the /boot/grub/grub.cfg is located. + Use (hd0,msdos1) for the first partition of the first disk if + using a legacy partition table, or (hd0,gpt1) if using GPT + partition table.
If we ask the user to include the parenthesis in this definition, then the menuconfig vision of this option looks a bit weird, because string options are already enclosed in parenthesis, so it looks like:
((hd0,msdos1)) boot partition
In menuconfig. Maybe we should instead ask for the value without the parenthesis, and add them in grub2.mk, so something like:
config BR2_TARGET_GRUB2_BOOT_PARTITION
string "boot partition"
default "hd0,msdos1"
Specify the partition where the /boot/grub/grub.cfg file is located. Use 'hd0,msdos1' for the first partition of the first disk if using a legacy partition table, or 'hd0,gpt1' if using GPT partition table.
(Notice also that I added the word 'file' in the first sentence).
Quoted 9 lines
config
BR2_TARGET_GRUB2_BUILTIN_MODULESboot/grub2/Config.in +0
-0string "builtin modules" default "boot linux ext2 fat part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PCboot/grub2/grub2.mk +0
-0@@ -11,9 +11,14 @@ GRUB2_LICENSE = GPLv3+ GRUB2_LICENSE_FILES = COPYING
boot/grub2/grub2.mk GRUB2_LICENSE = GPLv3+ · line 21
Quoted 10 lines
boot/grub2/grub2.mk +5
-0GRUB2_DEPENDENCIES = host-bison host-flex +GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) +GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) +GRUB2_BOOT_PARTITION = $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION)) + ifeq ($(BR2_TARGET_GRUB2_I386_PC),y) GRUB2_IMAGE = $(BINARIES_DIR)/grub.img GRUB2_CFG = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX = $(GRUB2_BOOT_PARTITION)/boot/grub
And then here, do:
# Yes, the partition specifier needs to be enclosed in parenthesis. GRUB2_PREFIX = ($(GRUB2_BOOT_PARTITION))/boot/grub
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com