Previously, grub-mkimage embeds full-featured grub.cfg inside core.img
during efi image generation phase (target/linux/install).
This causes grub to not passing kernel command line to the kernel, which
causes kernel panic when the generated gpt image is booted on bios mode
because the kernel doesn't find the root partition.
Fixing the problem involves using minimal grub-early.cfg to embed inside
grub's core.img to load the full-featured grub.cfg later.
grub-early.cfg contains one configuration line:
configfile (hd0,gpt1)/boot/grub/grub.cfg
With this change, the generated gpt image should be bootable on both
bios and UEFI based systems.
Signed-off-by: Alif M. Ahmad <alive4ever@live.com>
-e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \
-e 's#set root.*#search --file /boot/grub/$(SIGNATURE).cfg --set=root#g' \
./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg
+ sed \
+ -e 's/(hd0,msdos1)/(hd0,gpt1)/' ./grub-early.cfg > \
+ $(KDIR)/root.grub/boot/grub/grub-early.cfg
+
$(CP) $(KDIR)/root.grub/boot/grub/grub.cfg $(KDIR)/root.grub/boot/grub/$(SIGNATURE).cfg
grub-mkimage \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-o $(KDIR)/grub2/core.img \
-O i386-pc \
-p '(hd0,gpt1)/boot/grub' \
- -c $(KDIR)/root.grub/boot/grub/grub.cfg \
+ -c $(KDIR)/root.grub/boot/grub/grub-early.cfg \
$(GRUB2_MODULES_LEGACY)
$(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/