I've installed Fedora on my machine with /
partition, swap
partition and ESP
partition for EFI booting.
Now, I was installing Elementary OS instead of Fedora.
- I have formatted the
/
partition (/dev/sda3) - Formatted the swap partition (/dev/sda4)
- But did not format the EFI boot partition (/dev/sda1)
Now when i boot, i get my old grub menu that's was installed by Fedora.
I can only boot into Elementary OS by:
- Entering the boot menu.
- Selecting boot from EFI file
- Navigate through
/dev/sda1/
, to get theelementary
directory that containsgrubx64.efi
file. Which is/boot/efi/EFI/elementary/grubx64.efi
.
How can i fix that ? I thought of formatting the boot partition /dev/sda1/
with fat16
or something then re-installing grub on it.
My /dev/sda1
now contains this :
root@rafael:/home/rafael# ls /boot/efi/
EFI mach_kernel System
root@rafael:/home/rafael# ls /boot/efi/EFI/
BOOT/ elementary/ fedora/
root@rafael:/home/rafael# ls /boot/efi/EFI/fedora/
BOOT.CSV fonts gcdx64.efi grub.cfg grubx64.efi MokManager.efi shim.efi shim-fedora.efi
root@rafael:/home/rafael# ls /boot/efi/EFI/elementary/
grubx64.efi
Here's my efibootmgr
output :
BootCurrent: 003D
Timeout: 0 seconds
BootOrder: 2001,2002,2003
Boot0000* Notebook Hard Drive
Boot0010* Internal CD/DVD ROM Drive
Boot0011* Internal CD/DVD ROM Drive (UEFI)
Boot0012* Fedora
Boot0013* Fedora
Boot0014* Fedora
Boot0015* Fedora
Boot0016* Fedora
Boot0017* Fedora
Boot0018* Fedora
Boot0019* Fedora
Boot001A* Fedora
Boot001B* Fedora
Boot001C* Fedora
Boot001D* Fedora
Boot001E* Fedora
Boot001F* elementary
Boot2001* USB Drive (UEFI)
Boot2002* Internal CD/DVD ROM Drive (UEFI)
Any help would be appreciated.
Best Answer
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
Copy the kernel and initramfs to the ESP (EFI system partition)
Register kernel as boot option in UEFI
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: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.