help-grub
[Top][All Lists]
Advanced

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

Re: How does the grub efi know where to look for the grub.cfg?


From: Arjun Krishnan
Subject: Re: How does the grub efi know where to look for the grub.cfg?
Date: Tue, 8 Mar 2016 13:36:47 -0700

Ok, I think I understand. I looked at the grubx64.efi file again and
it does indeed store the uuid or lvmid of the boot partition (in
ascii). This was my original question. Thanks for your help.

On Mon, Mar 7, 2016 at 11:10 AM, Andrei Borzenkov <address@hidden> wrote:
> 07.03.2016 19:05, Arjun Krishnan пишет:
>> On Sun, Mar 6, 2016 at 10:33 PM, Andrei Borzenkov <address@hidden>
>> wrote:
>>
>>> 06.03.2016 18:34, Arjun Krishnan пишет:
>>>> On Sat, Mar 5, 2016 at 10:35 PM, Andrei Borzenkov <address@hidden>
>>> wrote:
>>>>> 05.03.2016 20:27, Arjun Krishnan пишет:
>>>>>> I installed grub-efi using
>>>>>>
>>>>>>     grub-install --efi-directory=/mnt/efi --boot-directory=/boot
>>>>>> --target=x86_64-efi
>>>>>>
>>>>>> I did not specify a root partition anywhere (like you used to have to,
>>>>>> when installing it to the mbr), so how does grub set its $root and
>>>>>> $prefix?
>>>>>>
>>>>>
>>>>> grub-install configures image so that it will look for disk where
>>>>> /boot/grub is located at boot time and set $root and $prefix
>>> accordingly.
>>>>>
>>>>>> So I looked at a dual booting system that has two efi grub
>>>>>> installations, ubuntu and arch. It has a /efi/ubuntu directory that
>>>>>> has a grubx64.efi file and a grub.cfg. This grub.cfg simply sets the
>>>>>
>>>>> On EFI binary can query firmware for path it was loaded from. GRUB image
>>>>> can be configured so that it will use this information as value of
>>> $prefix.
>>>>
>>>> This explains how GRUB finds the path it was loaded from, and hence
>>>> the grub.cfg if it's in the path.
>>>> But it doesn't explain the archlinux setup, where there is no
>>>> grub.cfg.
>>>
>>> I answered this in previous sentence.
>>>
>>> In that case, let me clarify my question so I understand it better. The
>> grubx64.efi is in the EFI partition under (hd0,1)/EFI/grub for example. On
>> my hard disk there are several possible root partitions, say (hd0,2) and
>> (hd0,3) both of which have boot/grub/grub.cfg.
>>
>
> grub image is configured by grub-install to look for filesystem which is
> set by --boot-directory and defaults to where /boot is located (at the
> time grub-install is run).
>
>> The efi binary is loaded from the EFI partition, and it queries the
>> firmware for the path it was loaded from. It was loaded from
>> (hd0,1)/EFI/grub. So it sets its prefix=(hd0,1)/EFI/grub. However, there is
>
> No, image created by grub-install does not do it. It looks for
> filesystem where /boot/grub was present at the time grub-install was
> invoked.
>
>> no grub.cfg inside ${prefix}/grub/.
>>
>
> Loaded image path is pretty much irrelevant for grub-install. It is made
> available for use in grub.cfg, but is not used otherwise.
>
>> There is, however, a grub.cfg on (hd0,2)/boot/grub/grub.cfg and
>> (hd0,3)/boot/grub/grub.cfg . But only one of the two is the correct one,
>> and of course, grub knows where to look for this since it was installed
>> with --boot-directory=(hd0,2)/boot/grub. Where is this information stored?
>>
>
> Information how to find /boot/grub is stored in created image. This
> information uniquely identifies one of existing partitions.
>
>>
>>>> Is it stored in the efi file?
>>>>
>>>
>>> No. It would make reconfiguring GRUB too difficult. When GRUB starts it
>>> reads $prefix/grub.cfg.
>>>
>>>>>> correct prefix and root. I suppose the --efi-directory is used as a
>>>>>> system root partition. However, inside /efi/arch I simply have a
>>>>>> grubx64.efi. The root and prefix are nowhere to be found. I even when
>>>>>> I tried to read the efi file in hex.
>>>>>>
>>>>>> How does the grubx64.efi on the arch side figure out the correct
>>>>>> system root partition?
>>>>>>
>>>>>>
>>>>>> Arjun
>>>>>>
>>>>>> _______________________________________________
>>>>>> Help-grub mailing list
>>>>>> address@hidden
>>>>>> https://lists.gnu.org/mailman/listinfo/help-grub
>>>>>>
>>>>>
>>>
>>>
>>
>



reply via email to

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