You are not logged in.

#1 2025-01-14 10:16:35

libretechsupport
Member
Registered: 2025-01-13
Posts: 5

[Resolved] How are grubx64.efi made?

Hello, I am trying to understand the arch boot process better. After following the Multiboot USB Drive guide and then fiddling with `grub-install` on various platforms, I finally was able to produce a customized EFI System Partition (ESP) that I mostly understand.

One of the things I am not understanding is the grubx64.efi or bootx64.efi file. I can see by running efibootmgr the path to what the UEFI spec simply refers to as "bootable image" (ref).

I know that this "bootable image" appears after running

grub-install --target=x86_64-efi --efi-directory=whatever --boot-directory=whatever

but I'm not sure how it is actually generated. In particular I'm not sure how much this file depends on the environment in which grub-install is run, if at all.

Where can I get more info about "bootable images" like grubx64.efi and bootx64.efi? Like if I wanted to make one from scratch, what would I need to do?

Last edited by libretechsupport (2025-01-14 21:56:42)

Offline

#2 2025-01-14 12:08:11

rep_movsd
Member
Registered: 2013-08-24
Posts: 148

Re: [Resolved] How are grubx64.efi made?

*.efi files are what are called UEFI binaries which are executables that run under the UEFI subsystem before anything else loads on the system
You can build almost any program to run under UEFI

The default UEFI boot sequence is to look for a FAT32 partition and launch EFI/BOOT/BOOT64.EFI
You can also add "boot" entries to the UEFI bios manually, or programmably (with efibootmgr for example)

grubx64.efi is a program that reads your generated grub config file and shows the menu for you to select what you want to do
The Linux kernel itself can be converted to a UEFI app and launched directly by a boot entry in the BIOS

Here is a guide for building your own UEFI apps - note that its not so easy to do disk access and so on - you get the barebones environment with a framebuffer and input device support
https://github.com/tianocore/tianocore. … pplication

Offline

#3 2025-01-14 12:28:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,182

Re: [Resolved] How are grubx64.efi made?

If you want to really really know, read grub(-install) source code or documentation. e.g. https://www.gnu.org/software/grub/manua … 02dinstall and the relevant docs for grub-mkimage

Generally speaking from a "what's happening" standpoint. that command you posted will generate grubx64.efi into efi-directory/EFI/GRUB/grubx64.efi which will read GRUB configuration from boot-directory/grub which is why when using grub-mkconfig to generate a grub config you then pass -o boot-directory/grub/grub.cfg.

Offline

#4 2025-01-14 21:56:21

libretechsupport
Member
Registered: 2025-01-13
Posts: 5

Re: [Resolved] How are grubx64.efi made?

So I'm taking away that an EFI application is just a regular old program compiled for an EFI target instead of something like ELF. That helps a lot!

I did look at the grub-install script and got scared, so that summary helps to know what I'm looking for in there. Thanks!

Last edited by libretechsupport (2025-01-14 22:28:19)

Offline

Board footer

Powered by FluxBB