Installing grub on esp partition without reinstalling EndeavourOS

As described in this previous forum thread, I have a multiboot system.

I would like to reinstall EndeavorOS grub, which was accidentally installed in BIOS mode, in UEFI mode to the ESP partition without having to reinstall EndeavourOS. EOS was installed last after Kubuntu. According to the current setup, using multiboot, Kubuntu UEFi Grub has so far started various operating systems, including EOS. The problem with this is that Ubuntu uses initrd instead of initramfs in the EOS Grub entry for the kernel, so EOS cannot be booted. After every Kubuntu kernel update, I have to manually correct the EOS kernel entries from initrd to initramfs and this is quite a dirty method. In addition, EndeavorOS installed in legacy BIOS mode cannot start Windows 10 that is also installed. The goal is to not have to change in the BIOS whether I start the system in UEFI or legacy BIOS, i.e. only UEFI Grub remains. If the EndeavorOS UEFI grub will be installed on the ESP partition, I would think that it will overwrite the Kubuntu UEFI grub used so far. My question is, is this possible without reinstalling EndeavorOS, and if so, how?

First, you probably need to change /etc/fstab to mount your EFI partition. It should be mounted to /boot/efi if you want to follow the EOS defaults.

Once that is tested, working, you need to make sure your machine is booted in EFI mode. One easy way to do this would be to use Kubuntu’s grub to launch EOS.

From there you should be able to simply run grub-install with the correct syntax. Something like:

sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=EndeavourOS

What is the correct syntax to correctly mount esp in fstab?

For example /dev/sdx /boot/efi defaults 0 0

How can you test that the ESP partition is mounted correctly? Booting in EFI mode does not need to be tested, I have been able to boot EndeavorOS from Kubuntu’s grub so far if UEFI first or UEFI only was set in the BIOS at startup.

In this case, can I be sure that this will overwrite the Kubuntu grub I’m using so far?

There isn’t really a “correct” way. The installer uses something like:

UUID=B10C-55FA                            /boot/efi      vfat    defaults,noatime 0 2

After modifying /etc/fstab run sudo mount /boot/efi which will read /etc/fstab and mount it. Then do ls /boot/efi and ensure your EFI files are there.

With UEFI, it doesn’t get overwritten like in the MBR days. They are all present at the same time and there is an order that is controlled by the firmware that the are prioritized. That grub-install command will probably set the EOS grub as the highest priority but if it doesn’t you can change the order in the BIOS or using efibootmgr.

In the meantime, I checked the settings. In any case, the ESP EFI system partition is automatically mounted to /boot/efi in EndeavorOS, as in Kubuntu, according to fstab.
This line is included in etc/default/grub, I think for compatibility reasons.

Preload both GPT and MBR modules so that they are not missed

In that case, carry on with the instructions. Boot into EFI mode and run grub-install as described above.

Thanks, I’ll do that.
By the way, I checked what can be selected for direct startup by pressing the F12 key after turning on the laptop. Kubuntu and Windows 10 can be started in EFI mode, but not EndeavorOS, because it was installed in legacy BIOS mode. There is also MX Linux installed on the machine, but it also cannot be booted in EFI mode. If I start the laptop in legacy BIOS mode, none of the selected operating systems can be started, not even EndeavorOS. In this case, I have to select SSD here and this will launch the EOS grub menu, it follows that grub has been installed in the MBR.
Interestingly, the EndeavorOS grub menu includes Kubuntu and is bootable, even though Kubuntu itself was installed in EFI mode, as was MX Linux, which is also bootable.

Below this level there is also an EFI directory and the files are in it, is that a problem?

That is what should be there.

Thanks for your comments. Everything works flawlessly. Even Windows 10 does not start from custom.cfg, but is included in the grub of EOS. I think custom.cfg can be deleted after that.
Other than that, I only made small tweaks: I changed the default startup entry of EndeavorOS, because for some reason the system starts with the LTS kernel, and I enabled submenus. After that, I don’t always have to do the dirty work for the EndeavorOS kernel entry in the Kubuntu grub after each Kubuntu kernel update, since the EOS grub is already in use by default.

During the original offline EOS installation, the problem was probably that the installer gave a warning that a small DOS partition was needed to boot with the legacy BIOS, and although the installation was done in EFI mode, I created the partition in question, so the EOS grub installed in MBR. Kubuntu was installed in EFI mode, and the EOS entry was included in its grub, so its own grub started the system by default if UEFI was selected as the boot in the BIOS.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.