[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading grub.cfg

From: Daniel Kiper
Subject: Re: reading grub.cfg
Date: Fri, 14 Apr 2023 19:29:15 +0200
User-agent: NeoMutt/20170113 (1.7.2)


On Wed, Apr 12, 2023 at 01:47:56PM +0200, Laszlo Ersek wrote:
> Hi,
> sorry for the beginner questions in advance.
> How does grub2 locate and read "grub.cfg"?
> My (very superficial) understanding is this:
> - grub2 relies on its own filesystem drivers; for example, it does not
> attempt to consume EFI_SIMPLE_FILE_SYSTEM_PROTOCOL directly on a UEFI
> system -- it presumably consumes the BlockIo and/or DiskIo protocols, as
> a dependency of its own filesystem drivers

Yep, here is the driver: grub-core/disk/efi/efidisk.c

> - in one of those detected filesystems, it locates "grub.cfg", and reads it.

It works in a bit different way. Please take a look at [1], [2], [3],
grub-core/kern/main.c:grub_load_normal_mode() and grub-core/normal/main.c.

> Is this more or less correct?
> What about the following dependency problem:
> - some filesystem driver is built as a grub2 module,
> - grub.cfg contains a matching "insmod" grub2 command, loading said module,
> - but "grub.cfg" is placed on a filesystem of that particular type.
> Is this a realistic problem? If so, how is it solved? Is there something
> obvious I'm missing?

Required filesystem drivers (modules) are embedded into GRUB core.img
and loaded automatically [4] (the picture mentions "stages" which are
legacy thing and should not be used when you speak about GRUB2; though
otherwise it is OK).

> Another question: assuming an EFI_SIMPLE_FILE_SYSTEM_PROTOCOL-based fs
> driver existed in grub2, a particular filesystem might then appear
> *twice* to grub2, once via its own "native" driver, and another time via
> the UEFI SimpleFs-backed driver.

Yes, if both drivers do not communicate between each other to remove duplicates
then a given filesystem can be seen twice through different paths.

> Would this be a problem?

Due to lack of write support in the GRUB, except an environment file,
it should not be big deal. Though I think it would be better if GRUB
uses only EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and ignores "own drivers"
where possible.

I hope that helps.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]