4

I was trying to install GRUB onto an USB drive. I want to create a multi-boot USB disk, but I am getting an EFI directory not found error. How can I successfully create an EFI partition on my USB flash drive?

msouth
  • 123
Yannik
  • 489

2 Answers2

6

You can use GParted for this task (create an EFI partition) ... to install it open a terminal and execute :

sudo apt install gparted  

Open GParted from the Dash, select the USB drive, create a new gpt partition table and then create some new partitions. Here is a presentation I made how to do it -> How to prepare a disk with GParted

cl-netbox
  • 31,491
4

Creating an EFI System Partition (ESP) can be done in several ways, but is only the start of what you need to do. An ESP is a partition with a GPT type code of C12A7328-F81F-11D2-BA4B-00A0C93EC93B (or, on an MBR disk, a type code of 0xEF) and that uses the FAT32 filesystem (although FAT16 or even FAT12 can generally be used). In Linux, libparted-based tools, such as GParted and parted, identify the ESP on a GPT disk by the presence of a "boot flag," so you must set that flag on the ESP -- but this works only on GPT disks. (I think that recent versions of libparted use the "esp flag" as a synonym for "boot flag," so you could set that instead. This might work on MBR disks, too, but I'm not positive of that.) In GPT fdisk (gdisk, sgdisk, and cgdisk), it's identified by a partition type of EF00.

If you create an ESP with GParted, it can create the FAT filesystem at the same time you create the partition. If you use parted or GPT fdisk, you'll need to do so by running mkdosfs or some other tool.

Once the partition is created, you must copy a boot loader to the file EFI/BOOT/bootx64.efi (assuming booting on x86-64 systems with 64-bit EFIs). You mention GRUB, and that can be tricky because GRUB relies on configuration files with locations embedded in the GRUB binary; but the standard Ubuntu GRUB looks to your hard disk for its configuration file. There are GRUB installation scripts that can help set things up automatically, but I'm not very familiar with them. You might want to consider using my rEFInd boot manager instead. It will automatically scan for boot loaders on startup, so it most likely will require very little configuration, and its configuration file resides in the same directory as the rEFInd binary.

One more caveat: If your USB drive is meant to be bootable on computers with Secure Boot active, you'll need to copy shimx64.efi, not grubx64.efi or refind_x64.efi, to the USB drive's EFI/BOOT/bootx64.efi file; then copy the follow-on boot loader as grubx64.efi. rEFInd might not be the best choice in this case, either, since using it would necessitate manually adding rEFInd's keys to every computer you use with Secure Boot active. (OTOH, if you just want to boot on one computer, that might be an acceptable cost.)

Rod Smith
  • 45,120
  • 7
  • 66
  • 108