I don't know why you're using grub in the first place. UEFI acts as a boot
loader and it allows to select different operating systems or individual
kernels from a boot menu. Although there are some exceptions, it usually is
not required to chain a second boot loader, grub in this case.
You mention, you installed elementary OS instead of Fedora, which means you
only need to load one operating system. Here I present a way to do it
without using grub. The kernel needs to be compiled with
EFI_STUB, if that's the case you can check with
grep EFI_STUB /boot/config-<version>
Copy the kernel and initramfs to the ESP (EFI system partition)
cp /boot/vmlinuz-<version> /boot/efi/EFI/elementary/vmlinuz-<version>.efi
cp /boot/initrd.img-<version> /boot/efi/EFI/elementary/initrd.img-<version>
Register kernel as boot option in UEFI
echo "root=UUID=<disk_uuid> ro quiet rootfstype=ext4 add_efi_memmap initrd=\\EFI\\elementary\\initrd.img-<version>" |
iconv -f ascii -t ucs2 |
efibootmgr \
--create --gpt \
--disk /dev/<disk> --part <partition_number> \
--label "Elementary OS" \
--loader "\\EFI\\elementary\\vmlinuz-<version>.efi" \
--write-signature --append-binary-args -
The --disk
argument takes the device name of the disk, e.g.
--disk /dev/sda
, the --part
argument takes the partition number
of the ESP, e.g. 4. You can find the ESP partition number with the
following command:
gdisk -l /dev/sda | awk '$6=="EF00" {print $1}'
Ensure that you repeat the steps after each kernel update
Either you this manually (just repeat the steps above) or you write
a small script which does the job. To fully automatise it, the
script could be hooked into the kernel post-install procedure, into
the initramfs post-update procedure and into the kernel postrm
procedure (to remove the UEFI boot entry). Actually, I don't know
why this isn't done by default in the distributions, it's just a few
lines of code.
Best Answer
After using ghex to examine my "BOOTX64.EFI" file in the efi partition I found this line.
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"