Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've installed Fedora on my machine with / partition, swap partition and ESP partition for EFI booting.

Now, I was installing Elementary OS instead of Fedora.

  1. I have formatted the / partition (/dev/sda3)
  2. Formatted the swap partition (/dev/sda4)
  3. But did not format the EFI boot partition (/dev/sda1)

Now when i boot, i get my old grub menu that's was installed by Fedora. I can only boot into Elementary OS by:

  1. Entering the boot menu.
  2. Selecting boot from EFI file
  3. Navigate through /dev/sda1/, to get the elementary directory that contains grubx64.efi file. Which is /boot/efi/EFI/elementary/grubx64.efi.

How can i fix that ? I thought of formatting the boot partition /dev/sda1/ with fat16 or something then re-installing grub on it.

My /dev/sda1 now contains this :

root@rafael:/home/rafael# ls /boot/efi/
EFI  mach_kernel  System

root@rafael:/home/rafael# ls /boot/efi/EFI/
BOOT/       elementary/ fedora/     

root@rafael:/home/rafael# ls /boot/efi/EFI/fedora/
BOOT.CSV  fonts  gcdx64.efi  grub.cfg  grubx64.efi  MokManager.efi  shim.efi  shim-fedora.efi

root@rafael:/home/rafael# ls /boot/efi/EFI/elementary/
grubx64.efi

Here's my efibootmgr output :

BootCurrent: 003D
Timeout: 0 seconds
BootOrder: 2001,2002,2003
Boot0000* Notebook Hard Drive
Boot0010* Internal CD/DVD ROM Drive
Boot0011* Internal CD/DVD ROM Drive (UEFI)
Boot0012* Fedora
Boot0013* Fedora
Boot0014* Fedora
Boot0015* Fedora
Boot0016* Fedora
Boot0017* Fedora
Boot0018* Fedora
Boot0019* Fedora
Boot001A* Fedora
Boot001B* Fedora
Boot001C* Fedora
Boot001D* Fedora
Boot001E* Fedora
Boot001F* elementary
Boot2001* USB Drive (UEFI)
Boot2002* Internal CD/DVD ROM Drive (UEFI)

Any help would be appreciated.

share|improve this question
1  
I can only suggest this set of articles, never used EFI myself: rodsbooks.com/efi-bootloaders/index.html, rodsbooks.com/efi-bootloaders/index.html, rodsbooks.com/gdisk/whatsgpt.html. –  Bob Jul 19 '13 at 19:41
1  
Does your UEFI implementation have any kind of boot selection menu like F8 or so? Please post efibootmgr output so it could be seen whether elementary's entry is there (seems it's not but to be sure). You might also like refind as your boot manager. Just in case you'd like a quick peek at E17 on that system there's an image that just works (490M ISO link) as well as weekly snapshots. It is probably inferior regarding E polis –  Michael Shigorin Jul 20 '13 at 11:00
    
@MichaelShigorin Ok, I've added efibootmgr output. –  Rafael Adel Jul 20 '13 at 20:17

2 Answers 2

I don't know why you're using grub in the first place. UEFI acts as a boot loader and it allows to select different operating systems or individual kernels from a boot menu. Although there are some exceptions, it usually is not required to chain a second boot loader, grub in this case.

You mention, you installed elementary OS instead of Fedora, which means you only need to load one operating system. Here I present a way to do it without using grub. The kernel needs to be compiled with EFI_STUB, if that's the case you can check with

grep EFI_STUB /boot/config-<version>

Copy the kernel and initramfs to the ESP (EFI system partition)

cp /boot/vmlinuz-<version> /boot/efi/EFI/elementary/vmlinuz-<version>.efi
cp /boot/initrd.img-<version> /boot/efi/EFI/elementary/initrd.img-<version>

Register kernel as boot option in UEFI

echo "root=UUID=<disk_uuid> ro quiet rootfstype=ext4 add_efi_memmap initrd=\\EFI\\elementary\\initrd.img-<version>" |
  iconv -f ascii -t ucs2 |
  efibootmgr \
    --create --gpt \
    --disk /dev/<disk> --part <partition_number> \
    --label "Elementary OS" \
    --loader "\\EFI\\elementary\\vmlinuz-<version>.efi" \
    --write-signature --append-binary-args -

The --disk argument takes the device name of the disk, e.g. --disk /dev/sda, the --part argument takes the partition number of the ESP, e.g. 4. You can find the ESP partition number with the following command:

gdisk -l /dev/sda | awk '$6=="EF00" {print $1}'

Ensure that you repeat the steps after each kernel update

Either you this manually (just repeat the steps above) or you write a small script which does the job. To fully automatise it, the script could be hooked into the kernel post-install procedure, into the initramfs post-update procedure and into the kernel postrm procedure (to remove the UEFI boot entry). Actually, I don't know why this isn't done by default in the distributions, it's just a few lines of code.

share|improve this answer
    
Hmmm, I did grep EFI_STUB /boot/config-3.2.0-49-generic but got nothing. –  Rafael Adel Jul 19 '13 at 20:59
    
kernel 3.2 is too old (it's from January 2012) to support EFI_STUB. You need at least kernel 3.3. –  Marco Jul 19 '13 at 22:01
    
@RafaelAdel If you don't want to build your own kernel you can check for a newer kernel version in the software repositories. Elementary seems to be based on Ubuntu and a kernel 3.5 or 3.8 should be available. The newer ones are more likely to have EFI_STUB enabled. –  Marco Jul 19 '13 at 22:55
    
Actually there's kernel 3.10.1 now. Gonna give it a try. –  Rafael Adel Jul 20 '13 at 1:18
1  
Marco, advising stub use is irresponsible unless you're eager to guide each user through what's unsupported by his distribution and not pass it down like "do after each kernel upgrade". It's fine to have but not so fine to automate, I'm telling you this as a guy who's responsible for UEFI support in ALT Linux. –  Michael Shigorin Jul 20 '13 at 11:00
up vote 1 down vote accepted

I did it !

First of all, I removed all the unnecessary boot entries by:

efibootmgr -b <entry_hex_number> -B

Then, Reformatting the ESP partition with FAT32 filesystem.

mkfs.vfat -F32 /dev/sda1

Then installed grub to /dev/sda NOT /dev/sda1

grub-install /dev/sda
share|improve this answer
2  
You don't need grub-install which writes MBR. I don't know if you distro's grub does the two things together, but what you need is to copy grubx64.efi (or shim.efi) to /boot/efi/EFI/$distro/ and efibootmgr -c -l /boot/efi/EFI/$distro/grubx64.efi. –  Lingzhu Xiang Jul 21 '13 at 8:37
    
grub-install has learned to grok EFI (you can force it to with --target=x86_64-efi but efivars.ko must be loaded by that time anyways). –  Michael Shigorin Sep 4 '13 at 10:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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