As I understand it, the uefi bios loads grub.efi from the efi partition. This now loads a bunch of grub modules and the configuration file from the /boot directory.

But how does grub find the correct device in which the boot partition resides? In grub legacy, you'd usually install grub to a specific partition, using

# grub-install --root-directory=/dev/sda

So it's quite clear where it will look for the boot directory. How does grub-efi figure out the correct device?

  • as I understand it, the configuration for the location of the kernel is in the efi partition. – Joe Mar 5 '16 at 8:04
  • Clearly the information has to be in the efi partition, but you never really specify it at any point (like you used to have to) when installing grub. – user128063 Mar 5 '16 at 8:06
  • in the .efi file that is generated when you run grub-efi – Joe Mar 5 '16 at 8:08

After using ghex to examine my "BOOTX64.EFI" file in the efi partition I found this line.

search.fs_uuid a43d1f11-6ebe-477d-8be3-321a33bc37f9 root hd2,gpt4 
set prefix=($root)'/boot/grub'

This shows that the information for the location of grub (the boot partition) has been embedded by grub2-install into the BOOTX64.EFI file generated for the system.

Grub2 is then executed by the EFI loader and you get the grub interface to choose the operating system (kernel) to boot into or the default kernel is loaded.

Just to expand a bit: ".EFI" files are kind of like applications that the UEFI subsystem can execute. Intended to be used to both boot the system and provide a convenient place to run execution protection and anti-virus type programs.

They put the extensible in "Unified Extensible Firmware Interface"

  • It would be interesting to see if you could patch this file and change your configuration and uuid's and still boot without reinstalling Grub – Joe Mar 5 '16 at 8:31
  • Weird, I'm not able to find it. My ubuntu efi directory has a grub.cfg (in ascii) with the prefix and root information inside id. But my archlinux efi directory simply has a grubx64.efi that has no sign of the root and prefix commands you mentioned even when I read them in ghex. – user128063 Mar 5 '16 at 17:44
  • Not in ubuntu.efi look for boot.efi. the efi partition has a folder. Called efi and in it a folder called boot. – Joe Mar 7 '16 at 7:40
  • The efi folder has several efi binaries, one for windows, one for ubuntu and so on. The name of the efi file is irrelevant. The reason I wasn't able to find the uuid line is because my root partition is an lvm partition. It stores an lvmid instead! – user128063 Mar 9 '16 at 6:10
  • 1
    Oh, sorry I misread your previous post. Stackexchange cut off your previous post at the part where you described your system. Your description is of a single bootloader (grub) image (BOOTX64.EFI) that boots two operating systems as far as I can tell. Here are a few more possibilities: 1) steamos could also have it's own separate bootloader, for which it would have its own EFI file in the efi partition. 2) you have a hybrid EFI-legacy boot system where your steamos bootloader is stored in the MBR. You can see the efi bootorder is to use sudo efibootmgr -v on gentoo, but I'm sure you know this – user128063 Mar 9 '16 at 7:30

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.