Message ID | SG2PR0601MB19493291F2E4351C7688F1E3E4DB0@SG2PR0601MB1949.apcprd06.prod.outlook.com |
---|---|
State | Accepted |
Headers | show |
Series | [OpenWrt-Devel,1/2] x86: fix bios mkimage during efi image generation | expand |
Merged into my staging tree at http://git.openwrt.org/?p=openwrt/staging/jow.git. Thank you!
On Wed, Mar 14, 2018 at 07:18:10PM +0100, Jo-Philipp Wich wrote: > Merged into my staging tree at > http://git.openwrt.org/?p=openwrt/staging/jow.git. > > Thank you! > The next patch in series is not yet applied. https://patchwork.ozlabs.org/patch/881132/ My reason to simplify the image generation is as follows. 1. grub-bios-setup on ptgen-generated disk image is really unnecessary, since the resulting image will be converted to gpt later. No need for mbr boot sector here, since grub will use BIOS boot partition (EF02) instead of MBR when the performing grub-bios-install on the gpt disk image. Avoiding grub-bios-setup before gpt image has been generated saves several seconds on target/linux/install as well. Actually, grub-bios-install behaves the same to grub-bios-install-efi: setting up bios boot loader for legacy bios boot for both gpt and mbr disk. 2. There is no need to have 3 grub configurations. The previous fix for bios mkimage leaves grub-early.cfg inside /boot/grub. There is a cleanup performed on the next patch to remove grub-early.cfg, since it has been embedded inside grub-core.img. The grub-early.cfg should also be embedded for bootx64.efi, similar to how grub-early.cfg is embedded for bios core.img, so the resulting gpt image will have identical grub configuration for both bios and efi setup. With grub-early.cfg embedded inside bootx64.efi, the $(SIGNATURE).cfg is not needed anymore. grub.cfg is available and the content of $(SIGNATURE).cfg is identical to grub.cfg.
The original work is about a year old now, I think. What do we still need to make it into master? Also, how did the target/host Makefile issue for sfdisk end up being resolved? Thanks, -Philip > On Mar 14, 2018, at 12:18 PM, Jo-Philipp Wich <jo@mein.io> wrote: > > Merged into my staging tree at > http://git.openwrt.org/?p=openwrt/staging/jow.git. > > Thank you!
diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile index d5786fb2ad..c8dd94dc78 100644 --- a/target/linux/x86/image/Makefile +++ b/target/linux/x86/image/Makefile @@ -86,13 +86,17 @@ ifneq ($(CONFIG_GRUB_IMAGES)$(CONFIG_EFI_IMAGES),) -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/
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> --- Notes: This patch is based on Jow's staging repository instead of OpenWrt master branch. Hopefully, this would allow UEFI image generation for x86 targets, i.e. to get changes on Jow's staging repository merged into OpenWrt master branch target/linux/x86/image/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)