Install Grub2 in UEFI


I have overridden the MBR from Windows 10 using EasyBCD and now I can’t boot into any system.
So I’ve followed these instructions:
…but when I wrote “mount /proc” (and /sys) I got this error:

mount: /proc: mount failed: No such file or directory
mount: /sys: mount failed: No such file or directory

…when I wrote “grub2-mkconfig -o /boot/grub2/grub.cfg” I got this error:

/usr/sbin/grub2-mkconfig: line 130: /proc/self/mountinfo: No such file or directory

…and when I wrote “grub2-install /dev/sda” I got:

/usr/sbin/grub2-bios-setup: warning: this GPT partition label contains no BIOS Boot Partition; embedding won’t be possible
/usr/sbin/grub2-bios-setup: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.
/usr/sbin/grub2-bios-setup: error: will not proceed with blocklists.

I’ve found some threads googling these errors and generally people had this error with BIOS and I have UEFI. But I’ve come across this topic:
…but it’s too laconic for me (I’m not the brightest guy on Earth) and what’s worse, when I went into Rescue mode on my DVD with Opensuse 13.1 I got no command grub2-efi, grub2-efi-install, etc. The only command that starts with “grub” and contains “efi” is “grub2-glue-efi”, and it’s for Mac.

I guess my question is - how to burn a disk so it has grub2-efi command and generally how to install Grub2 with this disk (including creating ESP and other mysterious things)?
I would really appreciate the help since I have to use this computer for work tomorrow. And I don’t want to mess anything even more since I already “broke” the MBR.

You need to decide. You cannot have MBR and EFI and Windows (pick two).

And I do not understand what you are trying to do and how installing GRUB can help you to boot Windows.

Please start with telling what you are trying to achieve, not how you tried to do it.

Thanks for the reply.

I want to have Linux and Windows. Windows bootloader in UEFI doesn’t allow systems outside of Windows family. So I need Grub2 to be able to boot both Linux and Windows. And I want to have EFI since it’s newer than BIOS so I guess better.

And I gave a detailed description what I’ve done because people on the web are very rude otherwise if I don’t show that I’ve actually spent these 3 hours trying to solve the problem.

Just start with openSUSE install. Make sure installation DVD is booted in EFI mode (you need to consult your motherboard documentation how to do it). Then installer will install grub2, attempt to make it default boot option in firmware; and you will have possibility to add menu entry for Windows to GRUB, during installation or after.

And I want to have EFI since it’s newer than BIOS so I guess better.

It does not matter what is better - what matters is how Windows is installed. Linux must be installed in the same mode. But as you have GPT Windows most likely is installed in EFI.

I already have Linux installed. I installed it after Windows but was unable to add it to the bootloader and that’s why I’ve overriden MBR.

This is what “parted -l” in Secure mode shows me (I skipped “start” and “end” columns):

Number Size   File system    Name                         Options
1      315MB  ntfs           Basic data partition         hidden,diag
2      105MB  fat32          EFI system partition         boot
3      134MB                 Microsoft reserved partition msftres
4      321GB  ntfs           Basic data partition 
5      472MB  ntfs                                        hidden,diag
6      2150MB linux-swap(v1) primary
7      43.0GB ext4           primary
8      633GB  ext4           primary

Does that change anything? If not and I still should reinstall OpenSuse, which partitions should I format? Only the last 3?

Is Linux installed in EFI mode? Is /boot/efi mounted? Is /sys/firmware/efi present?

To make sure I’ve just reinstalled Opensuse using default partitioning (formatting home and root partitions).

In BIOS I have UEFI mode so I guess Linux is installed in UEFI mode.
During installation there was an info:

mounting point /dev/sda2 will be set to /boot/efi

…so I guess /boot/efi is mounted.

When I launch DVD with OpenSuse 13.1 in Rescue mode I have a directory /sys/firmware/efi when I log as root.

When I rebooted the computer after the reinstallation, Windows bootloader was launched and in boot queue it’s after booting from HDD. So something’s not right.

The EasyBCD stuff won’t work with EFI.

If you installed grub2-efi, then you should have a directory “/boot/grub2/x86_64-efi”. Check whether that exists.

It’s possible that you did it all correctly, but your computer BIOS is biased toward Windows. Maybe tell us what kind of computer this is, and someone might have specific help.

Now I know that EasyBCD won’t work with EFI because I’ve also done some googling but only after using it.

My /boot/grub2 is empty. Because as I said, I don’t have the command grub2-efi. How do I install grub2-efi?

I don’t know what information do you need. It’s a laptop, Acer, HDD+SSD. “dmidecode -t 2” told me that I have SMBIOS and my motherboard is Acer’s EA50_HWS v1.02.

As far as I know, ACER laptops are pretty good with UEFI.

To install grub2-efi:

Boot the live rescue CD (via USB is okay). Make sure that you boot it in UEFI mode. As a test, you can run:

# efibootmgr -v

If you get an error message about “efivars” then you are not in UEFI mode.

If you are properly booted, then:
mount your root file system as “/mnt”
mount other file systems (“/home”, “/boot” if a separate mount) on top of that.
mount the efi partition as "/mnt/boot/efi

# mount --bind /dev /mnt/dev
# mount --bind /proc /mnt/proc
# mount --bind /sys /mnt/sys

Then go into chroot mode to install grub2-efi

# chroot /mnt
# grub2-install --target=x86_64-efi
# shim-install    ### only needed for secure-boot

I’m away from my UEFI machine at present, so some of this is off the top of my head. I hope somebody will check and correct any errors.

After that (while still in chroot mode)

# grub2-mkconfig -o /boot/grub2/grub.cfg

After all of that, your BIOS (or, really, UEFI firmware) should be able to boot into a grub2-efi boot menu.

You installed in the wrong mode or overrode the default grub2-efi

If you can not boot to openSUSE then I say reinstall and be sure things are right for EFI boot.

First the first screen should have no options along the bottom. If so that is EFI if not that is legacy mode

If you booted the install media in EFI mode then all the rest sh9uld be default but always confirm

Second the EFI boot partition should be set to FAT and mounted to /boot/efi

Third the boot loader should be set to grub2-efi not to just grub2

Fourth if you have secure boot on in the BIOS then you must check the secure boot box else no need unless you plan on secure boot being on sometime in the future. I does not harm to check the box even if not using secure boot

Note if you can boot openSUSE then you can go to Yast-boot loader and change to grub2-efi there

Thank you both for answering!

efibootmgr showed that I was indeed in UEFI mode.
These are the commands I used (to be sure I didn’t mess up):

mount /dev/sda7 /mnt
mount /dev/sda8 /mnt/home
mount /dev/sda2 /mnt/boot/efi
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
grub2-install --target=x86_64-efi
grub2-mkconfig -o /boot/grub2/grub.cfg

grub2-mkconfig however gave me a few errors. Didn’t google them yet because I want to answer you first. Herethey are. (I’ll edit the picture to text in a bit, after reinstall)

efibootmgr showed me that I installed in UEFI mode. I don’t know if it was overriden.
I had no options at the bottom.
I did confirm everything while installing OpenSuse.
I’ll reinstall once again to be sure it was fat but I think it was since I went for the default options.
I know it should be grub2-efi and not grub2 but that’s the problem - I can’t seem to install this grub2-efi.
I have Secure boot checked and I always did so it wasn’t the problem.
My DVD with OpenSuse 13.1 doesn’t have liveCD option - only Secure boot. But I’ve launched LiveCD OpenSuse 12.3, run Yast, went to Boot Loader and when I clicked it I got:

Error: Because of the partitioning, the boot loader cannot be installed properly

…and when I tried to install grub2-efi with secure boot I got an error:

Error occurred while installing GRUB2-EFI

Since I can’t edit the post, here are the errors from grub2-mkconfig:

# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub.cfg ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
Found linux image: /boot/vmlinuz-3.11.6-4-desktop
Found initrd image: /boot/initrd-3.11.6-4-desktop
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
ERROR: opening path /mnt/sys/block
ERROR: failed to discover devices
  /dev/mapper/control: mknod failed: No such file or directory
  Failure to communicate with kernel device-mapper driver.
  Check that device-mapper is available in the kernel.
  No volume groups found

What’s weird is that the first 3 lines after the last ERROR doesn’t show up when I did the same thing from LiveCD instead of Rescue mode.

EFI boot partition is FAT and is mounted to /boot/efi.

Perhaps I should delete sda1 because it’s before sda2 on which is the EFI partition. Maybe sda1 is launched before sda2 and my bootloader is on sda2 since it’s the EFI partition?

Multiple EFI boot partitions are ok and the order does not matter. EFI boot is not the same as the old MBR boot the EFI BIOS looks for all the EFI boot partitions and the EFI boot partition(s) have FAT directories with the actual start up code. Looks like it thinks there is a LVM

Did you get errors on the mount or mount bind steps??

No I didn’t. I’d have mentioned it. Mounts went perfect.

Thanks for another answer. I hope to get this fixed tonight before work so I really appreciate any hints.

Grub-mkconfig will not work from rescue system. You need to chroot in your installed system to run it.

Well I spend a week solving the boot problem in my PC. I am not an expert but what I learn is that You have to put the first two sectors of the hard disk into the file. After doing this you will know where you are. Use dd when you start from any linux live-CD and place any 8 GB empty but formatted flash memory in USB to put your files into. I believe You will enjoy reading the hexadecimal codes but you can also placed it for others to help you read it.
You are not risking anything when you run the dd correctly.

@arvidjaar I know that. I’ve posted the commands I used and I always chrooted before using grub2-mkconfig.

@jpachucki I’m even less of an expert so I don’t want to copy disk sectors to a pendrive if you say it’s risky. But I’ve used gdisk to check MBR/GRUB and I have:

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 1953525168 sectors, 931.5 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): DEC8563F-DC5E-45DF-BDF1-21388B1D7E25
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1953525134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3437 sectors (1.7 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          616447   300.0 MiB   2700  Basic data partition
   2          616448          821247   100.0 MiB   EF00  EFI system partition
   3          821248         1083391   128.0 MiB   0C01  Microsoft reserved part
   4         1083392       628226047   299.0 GiB   0700  Basic data partition
   5       628226048       629147647   450.0 MiB   2700  
   6       629147648       633346047   2.0 GiB     8200  primary
   7       633346048       717238271   40.0 GiB    0700  primary
   8       717238272      1953523711   589.5 GiB   0700  primary

Perhaps I do have MBR on the first partition and it’s booted, ignoring the EFI partition? Should I remove every partition but the Windows one? Because I think that the way of solving my problem is what @gogalthorp suggested. That I have to install grub2-efi from LiveCD as it’s only a few clicks and once fixed my other problem with Grub. But I have to fix these errors.

I’ve found this topic:
…so perhaps I should manually change the grub.cfg file? What do you think?

You don’t have to remove anything just point the installer to the correct partitions. If you have a full install (not a live) then you can do an upgrade and correct through that. But in either case you must take charge and make the installer do what you want it to. It is best to actually boot the installer in MBR mode But I think you can manually change thing to EFI boo. In any case always triple check the partition scheme wscreen to make sure that it is how you want it. do not proceed until that screen shows all correct for yout

Again the requirments are

a FAT efi boot partition mounted as /boot/efi
use grub2-efi NOT grub2
Just check the secure boot box does no harm even if not using secure boot

Swap partition about = memory or a little more unless you have a ton of memory
root partition = 40 gig if default BTRFS file system 20-30 gig if ext4
home partition this is you stuff so make it as big as you think you will need for your stuff