How does grub find grub.cfg?

When booting with UEFI, EFI points to the efi-stub of grub in the EFI-partition.
grub will be started from there.

  1. grub needs to load grub.cfg
  2. grub needs to load its modules
  3. without its modules how can grub read the filesystem containing the modules and grub.cfg ?
  4. what if there are serveral partitions with differing grub.cfg ?
  5. :pencil: will grub load the first one, or does it know the UUID ?

:footprints:

Yes.

Yes.

Yes.

Some of the modules are already preloaded. The EFI stub is a binary file, and it contains the preloaded modules — e.g. support for the partitioning scheme, support for the filesystem that grub.cfg is on, et al.

The rest of the modules — i.e. the ones not strictly needed for accessing grub.cfg — are loaded from /boot once grub has mounted /boot as its own root filesystem.

Then you need a separate EFI stub (and a matching EFI variable in NVRAM) for each of them.


Note: Legacy BIOS boot is of course an entirely different thing. It’s a different process, which involves a raw read of the master boot record, and it requires a different version of grub.


Edit — since you added another question to your opening post after my reply…:

That question is non-sequitur, because a grub EFI stub can only point at one instance of grub, and thus you will need multiple EFI stubs — one for each installed system.

You would then of course also need to make sure that the respective /boot/efi/EFI/<name> directories are unique, and likewise for their EFI variables in non-volatile RAM.

The generic /boot/efi/EFI/boot/bootx64.efi will — or, at any rate, should — be a duplicate of the /boot/efi/EFI/<name>/grubx64.efi of the system installed last.

Given Manjaro’s custom implementation of grub, it is advised to let Manjaro’s grub be the dominant one. i.e. the entry in /boot/efi/EFI/boot/bootx64.efi should be a copy of /boot/efi/EFI/Manjaro/grubx64.efi.

3 Likes

If I understand correctly, it would be possible to set up a rescue system as follows:

  • One EFI partition,
  • Rescue system
    • Very small standard Manjaro installation(20GB)
    • Rename the folder to EFI/rescue/
    • GRUB in EFI/rescue/ points to the rescue system and the grub.cfg located there
  • Manjaro system
    • My normal system with all features
    • Including snapshots
    • Installed without formatting the EFI partition
    • GRUB in EFI/manjaro points to the normal system and the grub.cfg located there

Both systems could be booted via UEFI (or via GRUB if osprober is enabled)?

Is it possible/necessary to tell the rescue system that its own GRUB is located in EFI/rescue?
:footprints:

Installing rEFInd temporarily will allow you to chainload both Manjaro and the Rescue system – rEFInd will use it’s own btrfs efifs driver, and automatically detect both systems.

You could remove it again later, once you’re done.

1 Like

Yes, that would be advisable.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.