Ubuntu: How to create efi partition and install GRUB bootloader manually



Question:

I am currently struggling to install the grub bootloader in a efi partition created by myself. I am using a GPT partition table and I created some partitions where one of them is of type ESP (EFI System Partition) with its respective type UUID. I created a FAT file system within that volume by mkfs.fat -F32. Now I am hanging on the part of installing the GRUB bootloader.

My preferred way of doing this would be to just copy the GRUB binaries to the mounted EFI partition, but the binaries are not available anywhere and so this would not be the recommended way to approach this (I guess?). Would this work in theory (the UEFI firmwares seem to be able to read the fat file-system of the EFI partition, so why shouldn't I just copy the binaries)? So the common approach seems to be to use grub-install (from within some Linux OS, which I am running in a VM). The problem right now is, that I am not really sure what this does in the end. I want to install a plain EFI-Bootloader without any MBR-Legacy things, so this whole thing should only consist of files within the EFI partition, right? It seems quite opaque what grub-install does. After quite some effort to get it running out of the box, I installed the grub-efi-amd64 package. After a reboot I was able to install it, but I needed to specify a device. Which again confuses me, because considering the prior assumptions it should only need to know the mount-point of the EFI-partition. There seems to be an option called --efi-directory which probably should resolve this but if used, grub-install complains about me not specifying a device.

In my view it is also quite suspicious that the bootloader seems to be installed but the EFI partition is empty. I have a feeling that it was installed in the legacy-MBR way, can you confirm this? What would be your advice for me to reach the goal of a vanilla EFI grub installation? I would highly appreciate your help, thx in advance!


Solution:1

grub-install simply copies the binaries from /usr/lib/grub to /boot/efi, and configures the EFI system variables to point there. Just mount the ESP in /boot/efi and run grub-install. It still requires a device argument for backward compatibility, but it is ignored so you can specify anything you want. The Ubuntu installer just runs grub-install dummy.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »