The aim is to install Debian using debootstrap. First I want to install all system on a small 32GB flash disk.

And concepts of GPT partition tables and GRUB is quite clear: There is a table of partitions. Each partition has uniq ID. Further on each partition a filesystems created. FileSystem itself is the way to store files, journal, dirs and so on, it is a DataSturture.

Ok. Clear.

Now there is a ESP. A partition where the BOOTLoader is stored. And it must be FAT32 is not it?

Now I need to get kernel, ramdisk. Create a ESP on a FlashStick. And install GRUB so it going to be on the ESP and select appropriate Kernel and Ramdisk. And here I am stuck.

  1. How to create ESP? Is it a simple partition that further formated to FAT32?
  2. How to tell GRUB where to be installed? How to configure it? I know about grub-mkconfig - and I know that need to set linux and initrd but still a little bit confusing.

So here a problems begins.

How to connect ESP with a rest of FileSystem? How kernel knows where to search for all files and configurations?

That jump from starting GRUB and starting kernel passing parameters and mounting ESP into FileSystm looks weird and awkward.

Need help.

Thank you.

1 Answer 1


How to create ESP? Is it a simple partition that further formated to FAT32?

Yes, it is a simple partition, formatted to FAT32 (newer UEFI versions may accept other forms of FAT too), and the partition type UUID of a GPT-style partition table set to indicate it's an EFI System Partition (or ESP for short). If you are booting UEFI-style from a MBR-partitioned disk, the partition type code of the ESP should be set to 0xef instead of a regular FAT32 partition type code.

How to tell GRUB where to be installed? How to configure it?

To install GRUB, the grub-install command is used. It takes as a parameter the device name of the disk or partition to where GRUB should be installed.

If there is only one ESP on the disk (as is generally recommended), you can just specify the whole-disk device, e.g. /dev/sda or /dev/nvme0n1, just like you would do when installing a legacy BIOS-style GRUB. It will automatically find the ESP and write grubx64.efi in there, and also register it into UEFI NVRAM firmware variables (which you can view with efibootmgr -v).

If you are installing to a removable flash disk, you should also specify the option --removable to grub-install. If the disk is not removable as such, but you plan to move or clone it to another system, you should probably use the --force-extra-removable option instead.

Once GRUB is installed, grub-mkconfig - or a Debian-specific update-grub wrapper for it - can be used to create a GRUB configuration file.

In Debian, the standard mount point for the ESP is /boot/efi. Other distributions may do things differently.

When the system is booting UEFI-style, the firmware will first check its NVRAM boot variables for a boot order. A UEFI-style boot variable will specify a device, the ESP partition on it (identified primarily by the unique PARTUUID of the ESP), and a boot file to use within that ESP. In the case of a permanently-installed Debian distribution, the boot file pathname will be (Windows style, like the firmware will usually represent it) \EFI\debian\grubx64.efi, or \EFI\debian\shimx64.efi if a Secure Boot compatibility is also desired and the shim-signed and grub-efi-amd64-signed packages have been installed.

If there is no boot variable (e.g. because a removable media was selected for booting), a 64-bit x86 UEFI system will look for a pathname (in Windows style) \EFI\BOOT\BOOTx64.efi. If GRUB was installed using the --removable or --force-extra-removable options, this will actually be a copy of grubx64.efi.

So, the firmware will start GRUB, and then GRUB will read \EFI\debian\grub.cfg from the ESP. It will normally contain just a search command that will tell GRUB to find whatever partition contains /boot/grub using its UUID, and then the commands required to read /boot/grub/grub.cfg from there. (Depending on how the system is set up, this could refer to the root filesystem, or a separate /boot filesystem - either way is fine.)

After reading the real configuration from /boot/grub/grub.cfg, GRUB will know where to find the kernel and initramfs files, and what menu items to present to the user. GRUB will then load the selected kernel and initramfs files, pass the specified kernel boot options to the kernel command line, and then it will start the kernel. At this point, the boot-time jobs of GRUB, the ESP, and the /boot directory are all done - from this point onward, the boot can proceed without them.

The kernel will find the root filesystem based on the root= kernel boot option and any scripts within the initramfs, and once the root filesystem is located, checked (if necessary) and mounted, the boot process will be able to access the real /etc and proceed according to the information found in there.

At boot time, the kernel will never need to access /boot nor the ESP - when the kernel starts up, the bootloader and the firmware will have already read all they need from there. The ESP is mounted to /boot/efi only to allow for easy updates of the bootloader and its configuration. If you plan to never do that (e.g. in an embedded appliance system that will receive any updates by a total reimaging), you could leave the ESP completely unmounted.

  • Most important thing that made it tricky for me, is the step from grubx64.efi to grub.cfg. grub.cfg is a shell script. Commands in the shell script are clear. And this step is because grubx64.efi has hardcoded path (UUID + PATH) to grub.cfg inside. And the tricky part is that when installing GRUB need to modify not only cfg but the binary as well. That was opaque. I found it a "How does the grub efi loader find the correct grub.cfg and boot directory?" here, at the stackexchange. You made an amazing answer. It's is huge work. I really appreciate. Thank you a lot! Commented Feb 4 at 14:27
  • "So, the firmware will start GRUB, and then GRUB will read \EFI\debian\grub.cfg from the ESP" At the Manjaro, ESP does not have grub.cfg. ESP only contains grubx64.efi. Commented Feb 4 at 14:33
  • 1
    GRUB can be set up in many ways, and for UEFI, no One True Way has yet been established. Each distribution - and even each major release of a distribution - can do it differently. I've been trying to make an analyzer program that would unpack the grubx64.efi to find out the contents of any hardcoded config path and any other embedded info. Some distributions have the embedded path point directly to /boot/grub/grub.cfg, others use a bit of indirection with a mini .cfg file in either the same directory as grubx64.efi/bootx64.efi, or in \EFI\<distro>\grub.cfg.
    – telcoM
    Commented Feb 4 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .