Linux Boot – How to Create an EFI System Partition

biosbootlinuxpartitioningwindows 8

TL; DR How do I create an EFI system partition from scratch? How do I put the EFI firmware on it onces it is created?

Long version

I hava Toshiba T430 laptop. I received it with Windows 7 installed (but I think originally it has shipped with Windows 8). I installed Ubuntu on it, but deleted some partitions on the disk so that I ended up wiping out the Windows and only having Ubuntu. Among the deleted partitions was the EFI System partition. I discovered that Ubuntu now boots in Legacy mode (and not UEFI). I am trying to follow this guide on converting my Ubuntu installation from Legacy to UEFI. The problem – since there is no EFI partition whenever I choose from BIOS to boot using UEFI I cannot boot. That counts not only for the harddrive, but usb and DVD as well. I think this is logical – it expects an EFI partition and since it can't find it, it cannot continue booting futher, be it from HDD or DVD. So how do I recreate the EFI partition?

The guide above says:

Creating an EFI partition

If you are manually partitioning your disk
in the Ubuntu installer, you need to make sure you have an EFI
partition set up.

  1. If your disk already contains an EFI partition (eg if your computer
    had Windows8 preinstalled), it can be used for Ubuntu too. Do not
    format it. It is strongly recommended to have only 1 EFI partition per
    disk.

  2. An EFI partition can be created via a recent version of GParted
    (the Gparted version included in the 12.04 disk is OK), and must have
    the following attributes:

    1. Mount point: /boot/efi (remark: no need to set this mount point when
      using the manual partitioning, the Ubuntu installer will detect it
      automatically)

    2. Size: minimum 100Mib. 200MiB recommended.

    3. Type: FAT32

    4. Other: needs a "boot" flag.

I had some trouble creating this partition:

  • I boot from a live Ubuntu DVD, open GParted, create a 200MB partition and format it to FAT32.
  • In GParted I cannot set the mount point and thus cannot set the bootflag.
  • I didn't set the mount point in /etc/fstab since it's a live CD and fstab looked quite differently from what I expected compared to a normal boot. Anyway, I just didn't know what values to set.

I booted again via the live DVD and then chose to install Ubuntu. I then created a partition with the mentioned criteria – mount point, 200MB, FAT32, boot flag.

However, I continue to have this problem and I suppose it's because on that partition there is no EFI firmware, it's just an empty partition, which is suitable to have EFI firmware.

So again, how do I create an EFI partition, which has the EFI software, so that the laptop can once again boot in UEFI mode?

SOLUTION Thank you both for the answers. What I did was install Windows 8.1 from scratch by formatting the whole disk and then installing (this time properly) Ubuntu next to it. These are my partitions now:

Disk partitions

During the Win 8 setup, as soon as I deleted all existing partitions and let Windows reformat the disk, it automatically created, besides the main install partition, three additional partitions, namely 1, 2, 3. Now, after I had a proper ESP, I could boot both from HDD or DVD in UEFI mode.

You say that the ESP doesn't store any info by default, but I guess that when an OS installs, it puts some info there. So I guess my case was the following: I had wiped it out and even though I recreated it, it was not filled with any info, since the creation of the ESP was done after an OS had been installed. I lost the Ubuntu installation (no big deal, it was a fresh install anyway), but I guess that in order to save it, I should have followed grawity's advice. Didn't have time, though, but happily everything is fine now.

Best Answer

First, you don't set the mount point in GParted; that's done manually (and temporarily) via the mount command or permanently by editing /etc/fstab. Thus, your concern over this issue is misplaced.

Second, an EFI System Partition (ESP) is simply a FAT partition with a particular type code (namely, C12A7328-F81F-11D2-BA4B-00A0C93EC93B on GPT disks) set. Note that the mount point in /etc/fstab is not part of the ESP's definition; it's just conventional (but not required) in Linux to access the ESP by mounting it at /boot/efi, typically via an /etc/fstab entry. How you set the type code varies from one program to another:

  • In gdisk, you set the type code to EF00. (gdisk uses two-byte type codes that expand out to the real type codes on the disk; "EF00" is just a mnemonic for "C12A7328-F81F-11D2-BA4B-00A0C93EC93B".)
  • In GParted or parted, you set the "boot flag." Note, however, that this works only on GPT disks; you cannot set the ESP type code on MBR disks with these programs. (This isn't normally a big deal, since EFI-based computers usually boot from GPT disks.)
  • In the Ubuntu installer, you identify the partition as an "EFI boot partition." It then sets the type code and will set up /etc/fstab appropriately.
  • In recent versions of Linux fdisk, you set the partition type by its number (1 for "EFI System" on GPT disks or 0xEF on MBR disks) or by entering the full type code on GPT disks.

Third, the ESP does not hold firmware -- firmware is, by definition, stored in chips on the motherboard. Thus, your effort to install the EFI firmware on the ESP is a wild goose chase. (There are two exceptions to this rule. First, you might store a firmware file on the ESP in order to update the firmware on your computer. This is just a temporary holding area, though. Second, the DUET or Clover boot loader, the EFI is loaded as a regular program, typically from the ESP. These tools are BIOS boot loaders, though, that enable BIOS-only computers to boot as if they were EFI machines; they are not normally used on computers with EFI firmware, which you claim your computer has. Technically, neither DUET nor Clover is firmware; they're BIOS boot loaders that do the same job as EFI.)

Finally, I can think of a number of possible causes for your problem, but without further information, I'd need to write half a book to cover them all. I recommend you run the Boot Info Script on the computer. This will produce a file called RESULTS.txt. Post it to a pastebin site and post back with the URL to your document. That will give hard data on your configuration, which will greatly reduce the range of possible causes of your problem.

Related Question