UEFI – How to Restore EFI Boot Partition

uefi

I am triple booting Ubuntu, Debian, and Fedora. When I installed Fedora from a liveCD I got excited and kept hitting next, not realizing I was not installing GPT, but rather LVM.

After doing this I cannot boot from a hard disk. The EFI menu doesn't even show my hard drive as a boot option (although it detects it in hardware).

I have a work-around currently, which is odd in how it works, I use a liveboot USB (Yumi) and choose to run Linux from hard drive, and I can choose between the distros I have on my computer. However I need this USB to boot into a distribution.

I am unsure exactly how to restore my system.

My computer came with Ubuntu installed, ASUS XC200 (netbook). I called Asus tech support, they wanted to re-image.. I will not give up so easily.

My /dev/sda1 (fat32, with boot flag) has an EFI directory on it for Ubuntu (assuming Ubuntu was loading GRUB> chainloading Debian).

How do I start to fix this? And what information do people need?

(I have no CD/DVD Player)

Note with efibootmgr:

Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.

When I run modprobe there is nothing with efivars.


Update/Things I tried so far:


I tried the answers posted below [1], [2] currently, good research, and in most cases I believe they would work. They did not however in my situation.

Current Tools

Disks–

  • Lost extra flashdrives with Kali
  • & Debian
  • & Ubuntu 14.04
  • still have Yumi with Ubuntu 12.04.

Steps taken recently (after following answers):

  • Ran Live Ubuntu
  • Wiped /dev/sda except the fat partition (GPT/ESP)
  • Tried to do install of Ubuntu, didn't work problem with grub and EFI on my GPT partition
  • Used fsck just in case (fine)
  • Used parted/gparted to wipe all then make GPT and other partitions(set boot flag on ESP)
  • Tried Install again (didn't work same error)
  • Partitions looked funny, (missing space)… Scratched Head
  • Wiped partitions/Made partition for LiveUSB onto Harddrive
  • Used dd to write LiveUSB to /dev/sda4 (believe this was number)
  • This booted, but needed my USB to be in place so was useless
  • Tried to use gfdisk, made me reboot lost session
  • Split my LiveUSB
  • Downloaded Arch .iso, and dd'd onto 2nd USB partition (LiveUSB)
  • Kept Ubuntu LiveUSB session up, went through partial install (up to chroot of Arch while in live session)
  • Had problems with things working right
  • Ran Arch Live, went through install (zapping and initial creation of partitions worked better than on parted/gparted)
  • Used directions to dosyslinux (from within Arch Install Guide)
  • Basically rewrote all my efi to brand new
  • Running great on Arch
  • Unsure whether/how to answer my own question

Best Answer

Forget grub entirely - it is nothing but a distraction. It isn't even a boot-loader anymore; on EFI systems the bootloader is built-in to the firmware. grub is just a boot-manager in that context - and almost definitely entirely redundant. What's more - it is probably the grub install that broke everything in the first place.

These are the things you need:

  1. A FAT-formatted GPT partition of type ef00.
  2. A UEFI-compatible system kernel located on that partition (such as the linux kernel).
  3. The path to that system kernel saved to a UEFI environment variable (commonly Boot0000-{UUID}, but this also depends on the value of BootOrder-{UUID}).

Strictly speaking, that is all. You can achieve the above setup with nothing more than gdisk and the efibootmgr command-line tools.

Pragmatically, a boot-manager does make sense - but grub is the most complicated of all of those available. As is elsewhere recommended, rEFInd is probably the best of the bunch.

I have written a step-by-step tutorial before on how to partition, format, and setup a rEFInd-enabled EFI system partition before here. Here also is another answer on this subject, in which you might find some further explanation about the assertions I make here.

Related Question