0

Is the EFI directory a mandatory part of the EFI standard or can bootloaders be placed in other directories.

I'm contemplating moving my whole /boot over to the ESP partition (ensuring I have a large enough ESP partition). Now Debian based distributions (and others) have scripts which expect the ESP directory mounted at /boot/efi/ putting the EFI directory hard coded at /boot/efi/EFI.

So I see two options to work with this:

  • Mount ESP to /boot and then bind mount /boot/EFI to /boot/efi/EFI to satisfy the OS scripts.
    This needs both an efi and an EFI directory on a FAT32 formatted partition so I'm not entirely happy about doing this.
  • Install the bootloader to /efi/EFI on the ESP partition and tell the bios to took elsewhere for the bootloader (eg: /efi/EFI/ubuntu/grubx64.efi)

What I don't know is whether or not the EFI directory is a mandatory part of the specification, if I'm likely to get problems in my BIOS or if I can just safely move it.

  • My understanding is ESP must be FAT32 and /boot must be Linux formatted. I have seen where users installed using ESP, so UEFI finds correct GUID/partUUID and then change to another FAT32 for another ESP. But only one ESP per drive. If you want boot files in ESP look at systemD bootloader which does that. Systemd boot loader spec (was gummi boot: https://systemd.io/BOOT_LOADER_SPECIFICATION & https://www.freedesktop.org/wiki/Software/systemd/systemd-boot/ systemd-boot (f. gummiboot) https://blobfolio.com/2018/06/replace-grub2-with-systemd-boot-on-ubuntu-18-04/ – oldfred May 20 '21 at 12:46
  • @oldfred where do you get that /boot must be linux formatted from? From what I understand /boot is read by the bootloader only. EFI on the BIOS loads the boot loader, the bootloader loads the kernel and initramfs from /boot beyond that they are only mounted so that linux can manage their contents when it changes boot configuration (eg installing a new kernel). – Philip Couling May 20 '21 at 16:24
  • @PhilipCouling The /boot directory is written by Linux when the kernel is updated. Some distros may not be happy with a FAT32 formatted /boot directory. – Johan Myréen May 20 '21 at 16:31
  • The /boot partition or folder is part of Linux. https://en.wikipedia.org/wiki/Unix_filesystem#Conventional_directory_layout and it must be Linux formatted to support ownership & permissions. Windows formats like FAT32 & NTFS do not have Linux ownership & permissions. The ESP as FAT32 is required by UEFI for UEFI to find the UEFI boot files. Do not confuse Linux /boot with UEFI ESP which is used for booting but is not /boot. It may be mounted in /boot, see answer below. – oldfred May 20 '21 at 20:00
  • @oldfred and it must be Linux formatted to support ownership & permissions where do you get this from? It's not instantly obvious from it's purpose that any of that is needed. Is it mentioned in posix, the filesystem hierarchy standard or any linux kernel documentation? Just being mentioned in FHS doesn't instantly infer any such requirements. – Philip Couling May 20 '21 at 20:35
  • The only time I have seen anything about not using Linux format for /boot was SystemD. But I have not used nor really know SystemD. – oldfred May 20 '21 at 22:16

1 Answers1

0

The UEFI bootloaders are searched based on paths stored in EFI variables in non-volatile storage. By convention, the variables contain paths to locations under the EFI directory relative to the root of the ESP, for example /EFI/ubuntu/grubx64.efi. I don't think it is a good idea to deviate from this convention. The firmware ("BIOS") does not care where the ESP is mounted on Linux, or if it is mounted at all. For example, the ESP can be mounted on /boot, which combines the traditional Linux /boot directory and the ESP. This means /boot is FAT32, which is possible, but perhaps not optimal: some distros are not happy if they can't create links in /boot. The ESP can also be mounted on /boot/esp, where /boot can be a separate boot partition, or it can be on the root partition.

To satisfy the /boot/efi/EFI requirement of the OS scripts, you can either mount the ESP on /boot/esp, or you can, for example, mount the ESP on /efi, and create a symlink /boot/efi that points to /efi.

Johan Myréen
  • 13,168
  • I don't think your final suggestion would help me much. The problem is that /boot contains things in the root directory. So if I want to place it's whole contents on the ESP partition I can't have symlinks there as you point out. Mount points are the only way round I've found. – Philip Couling May 20 '21 at 20:45
  • @PhilipCouling If the /boot directory is on the ESP partition, you can't have symlinks there. If /boot is required to support links, you need to have the ESP on a separate partition, i.e. you can't move /boot to the ESP, which I guess was the motivation for your question. The idea in Debian is to mount the ESP on /boot/esp, which is hard-coded in the scripts. – Johan Myréen May 21 '21 at 16:42
  • The whole subject of this question is finding a way to put it there. It is useful to know this might not work on all distributions. But I'm unclear on what your suggestion is trying to achieve if not that. – Philip Couling May 21 '21 at 17:07