Skip to contentSkip to conversation

grub-lnstall option (UEFI) for chainloading

DISCUSSION Barry Jackson 5 participants 12 messages Mar 29, 2015 – Jun 6, 2016

lore
Share & tools
lore
#0 lore raw

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

#1 lore raw

В Sun, 29 Mar 2015 13:11:04 +0100
Barry Jackson <[email protected]> пишет:

Quoted 10 lines

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

Yes, for a long time I cherish idea of "only update /boot/grub and create core.img" option. May be something like generic

--no-platform-setup

that will simply exit after image is created. --no-nvram is too specific name to roll this into it. We can then deprecate --no-bootsector and --no-nvram (actually as --no-bootsector is new just drop it).

Vladimir, will you agree to a patch?

#2 lore raw
Quoted 17 lines · Andrei Borzenkov

В Sun, 29 Mar 2015 13:11:04 +0100
Barry Jackson <[email protected]> пишет:

Quoted 10 lines

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

Yes, for a long time I cherish idea of "only update /boot/grub and create core.img" option. May be something like generic

Quoted 7 lines

--no-platform-setup

that will simply exit after image is created. --no-nvram is too specific name to roll this into it. We can then deprecate --no-bootsector and --no-nvram (actually as --no-bootsector is new just drop it).

GRUB already has --no-nvram for EFI.
--no-nvram has different meaning than what you describe. --no-nvram still copies all the files to their target destinations, in EFI case to ESP, just doesn't register them in NVRAM. It's useful if you want to fix GRUB setup on another computer by plugging its disk in USB enclosure. I'm unclear about which semantics you want. Should --no-platform-setup still put boot.img to $prefix/i386-pc ? Probably yes, but it's already part of platform-dependent install. Should we split the switch (platform) in grub-install to 2 switches then ?

Quoted 7 lines

Vladimir, will you agree to a patch?

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 27 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 19 lines · Andrei Borzenkov

В Sun, 29 Mar 2015 13:11:04 +0100
Barry Jackson <[email protected]> пишет:

Quoted 10 lines

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

Yes, for a long time I cherish idea of "only update /boot/grub and create core.img" option. May be something like generic

Quoted 7 lines

--no-platform-setup

that will simply exit after image is created. --no-nvram is too specific name to roll this into it. We can then deprecate --no-bootsector and --no-nvram (actually as --no-bootsector is new just drop it).

Quoted 7 lines

GRUB already has --no-nvram for EFI.
--no-nvram has different meaning than what you describe. --no-nvram still copies all the files to their target destinations, in EFI case to ESP, just doesn't register them in NVRAM. It's useful if you want to fix GRUB setup on another computer by plugging its disk in USB enclosure.
I'm unclear about which semantics you want. Should --no-platform-setup still put boot.img to $prefix/i386-pc ?

Yes. It should copy modules to /boot/grub, run usual $prefix detection, create core.img (whatever name for the current platform it has) but stop here. In particular, it should not copy it into ESP on EFI :)

Quoted 2 lines

Probably yes, but it's already part of
platform-dependent install.

I do not insist on this name. I just cannot think about better alternative.

Quoted 2 lines

Should we split the switch (platform) in
grub-install to 2 switches then ?

Not sure I understand it, sorry.

There main use case is master bootloader that chainloads (in broad sense) bootloader for each installed system. In this case we do NOT want core.img to be copied anywhere, because master bootloader will load it. We DO want it to be fully functional core.img though, including working reference to $prefix.

#4 lore raw
Quoted 58 lines · Andrei Borzenkov
Quoted 27 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 19 lines · Andrei Borzenkov

В Sun, 29 Mar 2015 13:11:04 +0100
Barry Jackson <[email protected]> пишет:

Quoted 10 lines

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

Yes, for a long time I cherish idea of "only update /boot/grub and create core.img" option. May be something like generic

Quoted 7 lines

--no-platform-setup

that will simply exit after image is created. --no-nvram is too specific name to roll this into it. We can then deprecate --no-bootsector and --no-nvram (actually as --no-bootsector is new just drop it).

Quoted 7 lines

GRUB already has --no-nvram for EFI.
--no-nvram has different meaning than what you describe. --no-nvram still copies all the files to their target destinations, in EFI case to ESP, just doesn't register them in NVRAM. It's useful if you want to fix GRUB setup on another computer by plugging its disk in USB enclosure.
I'm unclear about which semantics you want. Should --no-platform-setup still put boot.img to $prefix/i386-pc ?

Yes. It should copy modules to /boot/grub, run usual $prefix detection, create core.img (whatever name for the current platform it has) but stop here. In particular, it should not copy it into ESP on EFI :)

Quoted 2 lines

Probably yes, but it's already part of
platform-dependent install.

I do not insist on this name. I just cannot think about better alternative.

Quoted 2 lines

Should we split the switch (platform) in
grub-install to 2 switches then ?

Not sure I understand it, sorry.

There main use case is master bootloader that chainloads (in broad sense) bootloader for each installed system. In this case we do NOT want core.img to be copied anywhere, because master bootloader will load it. We DO want it to be fully functional core.img though, including working reference to $prefix.

Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Any progress on this?

#5 lore raw

В Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> пишет:

Quoted 59 lines · Andrei Borzenkov
Quoted 58 lines
Quoted 27 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 19 lines · Andrei Borzenkov

В Sun, 29 Mar 2015 13:11:04 +0100
Barry Jackson <[email protected]> пишет:

Quoted 10 lines

Hello,
Currently when installing grub2 on UEFI, the running system's grub2 writes an entry to the ESP making it the controlling grub.

Can an option to grub2-install be added that installs only to /boot/grub2 and creates core.efi, but does *not* write into the ESP?

This would provide similar functionality to the --no-bootsector option used in PC-BIOS systems for using a Master grub partition that chainloads into multiple operating systems.

Yes, for a long time I cherish idea of "only update /boot/grub and create core.img" option. May be something like generic

Quoted 7 lines

--no-platform-setup

that will simply exit after image is created. --no-nvram is too specific name to roll this into it. We can then deprecate --no-bootsector and --no-nvram (actually as --no-bootsector is new just drop it).

Quoted 7 lines

GRUB already has --no-nvram for EFI.
--no-nvram has different meaning than what you describe. --no-nvram still copies all the files to their target destinations, in EFI case to ESP, just doesn't register them in NVRAM. It's useful if you want to fix GRUB setup on another computer by plugging its disk in USB enclosure.
I'm unclear about which semantics you want. Should --no-platform-setup still put boot.img to $prefix/i386-pc ?

Yes. It should copy modules to /boot/grub, run usual $prefix detection, create core.img (whatever name for the current platform it has) but stop here. In particular, it should not copy it into ESP on EFI :)

Quoted 2 lines

Probably yes, but it's already part of
platform-dependent install.

I do not insist on this name. I just cannot think about better alternative.

Quoted 2 lines

Should we split the switch (platform) in
grub-install to 2 switches then ?

Not sure I understand it, sorry.

There main use case is master bootloader that chainloads (in broad sense) bootloader for each installed system. In this case we do NOT want core.img to be copied anywhere, because master bootloader will load it. We DO want it to be fully functional core.img though, including working reference to $prefix.

Quoted 8 lines
Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

#6 lore raw
Quoted 10 lines · Andrei Borzenkov

В Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> пишет:

Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

#7 lore raw
Quoted 14 lines · Barry Jackson
Quoted 5 lines · Andrei Borzenkov

В Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> пишет:

Quoted 7 lines
Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Quoted 5 lines

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

I was about to suggest a patch when I realized that this probably is currently useless on EFI. I.e. to actually chainload grub on EFI it must reside on a partition accessible by firmware which practically means it should be ESP.

Unless someone submits patch to make grub2 EFI core.img multiboot2 compliant with tag to skip ExitBootServices.

Does chainloading from /boot/grub actually work for you on EFI? Could you explain your configuration in more details?

#9 lore raw
In reply to Daniel Kiper

12.10.2015 19:39, Daniel Kiper пишет:

Quoted 27 lines · Andrei Borzenkov
Quoted 26 lines · Barry Jackson
Quoted 14 lines · Andrei Borzenkov
Quoted 5 lines

?? Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> ??????????:

Quoted 7 lines
Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Quoted 5 lines

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

I was about to suggest a patch when I realized that this probably is currently useless on EFI. I.e. to actually chainload grub on EFI it must reside on a partition accessible by firmware which practically means it should be ESP.

Quoted 6 lines
Quoted 2 lines

Unless someone submits patch to make grub2 EFI core.img multiboot2 compliant with tag to skip ExitBootServices.

Relevant patches waiting for review for months. I am working on v3. If they are upstreamed I will be happy too.

Your patches implement "client side" support (loading MB2 images); but EFI grub is not MB2 and has no provision for being loaded this way. Also it is PE, not ELF.

Actually chainloading probably could be made to work on arbitrary filesystem if argument parsing is added (to pass along cmdpath).

#10 lore raw
Quoted 28 lines · Andrei Borzenkov

12.10.2015 19:39, Daniel Kiper пишет:

Quoted 27 lines · Andrei Borzenkov
Quoted 26 lines · Barry Jackson
Quoted 14 lines · Andrei Borzenkov
Quoted 5 lines

?? Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> ??????????:

Quoted 7 lines
Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Quoted 5 lines

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

I was about to suggest a patch when I realized that this probably is currently useless on EFI. I.e. to actually chainload grub on EFI it must reside on a partition accessible by firmware which practically means it should be ESP.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Unless someone submits patch to make grub2 EFI core.img multiboot2 compliant with tag to skip ExitBootServices.

Relevant patches waiting for review for months. I am working on v3. If they are upstreamed I will be happy too.

Your patches implement "client side" support (loading MB2 images);

OK but they provide what you need here. So, it does not fully invalidate what I said earlier.

Quoted 2 lines

but EFI grub is not MB2 and has no provision for being loaded this way. Also it is PE, not ELF.

MB2 header may live in PE, ELF or even in file which does not have commonly known format.

Quoted 2 lines

Actually chainloading probably could be made to work on arbitrary filesystem if argument parsing is added (to pass along cmdpath).

So, it looks that MB2 with my extensions should make it work.

Daniel

#8 lore raw
In reply to Andrei Borzenkov
Quoted 21 lines · Andrei Borzenkov
Quoted 14 lines · Barry Jackson
Quoted 5 lines · Andrei Borzenkov

?? Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> ??????????:

Quoted 7 lines
Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Quoted 5 lines

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

Quoted 7 lines

I was about to suggest a patch when I realized that this probably is currently useless on EFI. I.e. to actually chainload grub on EFI it must reside on a partition accessible by firmware which practically means it should be ESP.

Unless someone submits patch to make grub2 EFI core.img multiboot2 compliant with tag to skip ExitBootServices.

Relevant patches waiting for review for months. I am working on v3. If they are upstreamed I will be happy too.

Daniel

#11 lore raw
In reply to Andrei Borzenkov
Quoted 26 lines · Andrei Borzenkov
Quoted 14 lines · Barry Jackson
Quoted 5 lines · Andrei Borzenkov

В Fri, 05 Jun 2015 14:56:20 +0100
Barry Jackson <[email protected]> пишет:

Quoted 7 lines
Quoted 2 lines

Any progress on this?

Not really, sorry. Do you have any suggestion how such option should be named?

Quoted 5 lines

Sorry for delay - this got lost in the noise.

Well something like --no-id-or-nvram ??

Not really bothered about the name! :)

I was about to suggest a patch when I realized that this probably is currently useless on EFI. I.e. to actually chainload grub on EFI it must reside on a partition accessible by firmware which practically means it should be ESP.

Quoted 6 lines

Unless someone submits patch to make grub2 EFI core.img multiboot2 compliant with tag to skip ExitBootServices.

Does chainloading from /boot/grub actually work for you on EFI? Could you explain your configuration in more details?

Sorry for the long delay I missed your reply. We could really do with a patch for this as Mageia 6 is in freeze. ;)

Yes it works fine from a separate small grub2 partition.

The grub2 install to the small dedicated grub2 partition is installed by my script here: https://wiki.mageia.org/en/User_talk:Barjac

This is my current grub.cfg created by the script:

set default="0"
set timeout=10

if loadfont unicode ; then
set gfxmode=1024x768x32 insmod all_video
insmod gfxterm
set locale_dir=/locale
set lang=en_GB
insmod gettext
fi
terminal_output gfxterm
insmod part_gpt
insmod ext2

# Theme
insmod gfxmenu
loadfont /grub2/themes/maggy/MageiaLogo-Bold-16.pf2 loadfont /grub2/themes/maggy/MageiaLogo-Bold-20.pf2 loadfont /grub2/themes/maggy/MageiaLogo-Bold-28.pf2 loadfont /grub2/themes/maggy/MageiaLogo-Regular-20.pf2 insmod png
set theme=/grub2/themes/maggy/theme.txt export theme

menuentry 'Mageia 6 on /dev/sda7' {
search --no-floppy --fs-uuid --set=root "a5ea7e67-7d24-4ecd-8271-fe662c87f258" chainloader /boot/grub2/x86_64-efi/core.efi
}

menuentry 'Mageia 5 on /dev/sda4' {
search --no-floppy --fs-uuid --set=root "6e0e6790-c318-4bbe-b3cf-e925391b4d16" chainloader /boot/grub2/x86_64-efi/core.efi
}

menuentry 'Mageia 6 on /dev/sda5' {
search --no-floppy --fs-uuid --set=root "18c8d8d4-dee6-4219-9dbf-a96d439ea76e" chainloader /boot/grub2/x86_64-efi/core.efi
}