3

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?

1
  • 1
    As Rod Smith mentions below, grub does not make it easy. It only installs to ESP on drive seen as sda. But then you have to copy /EFI/ubuntu to ESP on flash drive. Then copy again to /EFI/Boot and rename shimx64.efi to bootx64.efi and then update /etc/fstab with external drive's ESP's UUID. Best to do after install, but use the continue to use system as then you have more permissions to copy & edit files. askubuntu.com/questions/743095/… & ubuntuforums.org/showthread.php?t=2338836 – oldfred Feb 15 '17 at 17:07
5

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

0
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.)

2
  • What do you mean by "follow-on bootloader as grubx64.efi" ? And how do I copy shimx64.efi to the USB EFI/BOOT/bootx64.efi file? You mean I just need to replace the USB bootx64 with shimx64? – Glassjawed Feb 15 '17 at 18:12
  • The Shim program inserts itself into the firmware's Secure Boot code path and then launches a follow-on program called grubx64.efi. Thus, whatever program you want to be the actual boot loader/manager must be called grubx64.efi. (There are exceptions, but this comment provides insufficient space to cover them.) As to how to copy the files, you use whatever file management tools you like -- the text-mode cp, a GUI file manager, etc. If you're starting with a fresh ESP, there will be no bootx64.efi file; it's an empty filesystem, so you must create the path and copy the file. – Rod Smith Feb 15 '17 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.