Suppose I have a flash drive, and I want it to be bootable. Suppose I also have a basic EFI file which will accomplish something. So, what is the minimum size the ESP can be? I've read that it's 100MB, but that seems to be specifically in regards to windows. Must a EFI partition be a certain size for the system to recognize it? Or is 100 just recommended because modern operating systems use that much?
Is 100 just recommended because modern operating systems use that much?
Note that the 100 MB partition size is the minimum. Though there is no specification set by UEFI for a minimum size, but Microsoft recommends this 100 MB size for it's Operating Systems.
Let's think we need the EFI partition to be formatted using the FAT32 file system. The minimum partition size of FAT32 drive is calculated as
sector_size x 65527.
In Advanced Format 4K Native drives, there is 4 KB per sector. In that case, the minimum partition size for FAT32 drive is calculated as
4 KB x 65527 = 256 MB. That's why recommended minimum size for 4K drives is 260 MB.
But in Advanced Format 512e drives, the emulated sector size is 512 bytes. In that case, the minimum partition size for FAT32 drive is calculated as
512 bytes x 65527 = 32 MB, which is less than the 100 MB minimum size for this partition.
Must a EFI partition be a certain size for the system to recognize it?
Though Microsoft recommends 100 MB for its operating systems, the Linux forums suggest more for Linux based operating systems or for any dual boot or multi booting situations.
The author of gdisk suggests 550 MiB.
As per the Arch Linux forum, to avoid potential problems with some EFIs, ESP size should be at least 512 MiB. 550 MiB is recommended to avoid MiB/MB confusion and accidentally creating FAT16.
So, most common size guideline for EFI System Partition is between 100 MB to 550 MB. One of the reason behind this is it is difficult to resize later as it is the first partition on the drive. EFI partition may contain languages, fonts, BIOS firmware, other firmware related stuffs. There are some firmware/software that are installed into the the EFI partition instead of the data drive. And there are some that want the capability in the future to add things into ESP.
As it may be difficult to enlarge the size in case it is needed later and the Hard Disk size now a days is larger, a big number of size like 100 MB or 550 MB is recommended for ESP. But in general case, it uses only some Kilo Bytes of space.
Suppose I have a flash drive, and I want it to be bootable.
Though it is not clear from your statement, if you try to make your pen drive bootable as UEFI compatible drive for windows installation, then there is no need of creating extra ESP in the pen drive. Use rufus or similar tools which will take care of converting it into UEFI enabled drive. But ESP is needed in your hard drive when installing windows into that drive.
The absolute minimum size you can get away with, involves using a fat12 filesystem (so 32 KB), and in practice requires using some minimal boot manager that incorporates filesystem drivers for reading your primary partition -- and the kernel contained there -- which implies grub or rEFInd. A typical grub-install image will be around 200KB, which is still not bad at all.
I've been booting just fine with a 2MB fat12 ESP for quite some time now, so clearly it can be done!
I'm not entirely sure where the common advice to use 512MB comes from, but the Arch Wiki was recently amended by... me... to reference the possibility of fat12.
http://www.rodsbooks.com/linux-uefi/ seems to indicate at least fat16 should work fine except for confusing the Windows installer, which is not really relevant IMHO. The Arch Wiki seems to have based itself on that advice, but I'm not brave enough to totally rewrite it.
As I referenced in the Wiki, the UEFI spec mandates fat12 drivers. I've heard arguments that "only removable drives are mandated", leaving open the possibility that someone, somewhere, has or will write a UEFI implementation that includes those fat12 filesystem drivers but somehow forbids their use for mounting the UEFI system partition, but I personally consider this unlikely.
For Linux, in terminal, run
sudo fdisk -l to find out the sector size of your storage drive.
Since the EFI partition is formatted as FAT32, the minimum partition size of FAT32 drive is calculated as
sector_size x 65527. For modern storage that is 512 bytes x 65527 = 32 MiB. The EFI boot manager executable is around 125 KiB, so the 32 MiB minimum is more than necessary for the EFI partition size. There are other arguments for larger sizes, but unless you run in those particular situations, larger is not necessary.