[lfs-dev] Missing option for grub-install?

Bruce Dubbs bruce.dubbs at gmail.com
Mon Jan 21 12:59:22 PST 2019


On 01/21/2019 02:06 PM, Pierre Labastie via lfs-dev wrote:
> On 21/01/2019 18:21, Bruce Dubbs via lfs-dev wrote:
>> On 01/21/2019 09:05 AM, Pierre Labastie via lfs-dev wrote:
>>> On 21/01/2019 11:09, Xi Ruoyao via lfs-dev wrote:
>>>> On 2019-01-21 10:44 +0100, Pierre Labastie via lfs-dev wrote:
>>>>> Hi,
>>>>>
>>>>> My machine has an UEFI BIOS, so that I rarely run grub-install. But
>>>>> yesterday,
>>>>> I built a new qemu VM, with a non-UEFI (virtual) BIOS. When running
>>>>> grub-install, it failed with a message (sorry, I haven't saved it) telling
>>>>> that it could not find /usr/lib/grub/x86_64-efi. Running "grub-install
>>>>> --help"
>>>>> returned:
>>>>> ---------
>>>>> [...]
>>>>> --target TARGET    install GRUB for TARGET platform [default=x86_64-efi]
>>>>> [...]
>>>>> ---------
>>>>> so I had to run "grub-install --target i386-pc /dev/sda". But now that I have
>>>>> done that, "grub-install --help" returns:
>>>>> ---------
>>>>> [...]
>>>>> --target TARGET    install GRUB for TARGET platform [default=i386-pc]
>>>>> [...]
>>>>> ---------
>>>>>
>>>>> So the default seems to be what is already installed. Checking the source for
>>>>> grub-install confirms that. I must have taken a virtual disk used for a
>>>>> former
>>>>> VM with UEFI BIOS.
>>>>
>>>> No.  Grub 2.02 is detecting the target dynamically at runtime by checking if
>>>> /sys/firmware/efi is empty.  At first time your system was booted via UEFI so
>>>> this is not empty.  But at the second time your system was booted via Legacy
>>>> BIOS so this is empty.
>>>
>>> You are right about the process, but what amazes me is that the first boot was
>>> not particularly EFI. I had a DOS partitioning (not GPT), and no /boot/EFI
>>> dir, and yet it must have found something in /sys/firmware/efi since it
>>> proposed x86_64 as the default (I do have the EFI switches on in the kernel).
>>> Well, looks like it will be hard to reproduce.
>>>
>>>>
>>>>> Should we add this switch (--target i386-pc) to the grub-install command in
>>>>> the book?
>>>>
>>>> If the host is booted via UEFI we'll need that to install a non-UEFI Grub.
>>>> But I think it's dangerous (may break the booting process of the host).  We
>>>> should explain this option more seriously (maybe in a "NOTE" or even
>>>> "CAUTION").
>>>>
>>>
>>> Yes, that may break machines with only UEFI boot. I think the command should
>>> be written without "--target", as it is now, but a note should be added to
>>> explain that the --target option may be used if the wrong if the application
>>> default is wrong
>>
>> Agree.  Please do that when you get a chance.
> 
> I've added a note at r11503. Not sure I have the wording right.

I think it is fine.  Thanks you.

   -- Bruce




More information about the lfs-dev mailing list