How to reinstall grub2-efi bootloader?

Hi all!

My son fiddled with YaST > Bootloader under openSUSE 15.0, and somehow managed to make his ASUS laptop unbootable.
It is an EFI system.
It was a dual boot, windoze 10 and openSUSE 15.0.
That worked fine.

After that he was still able to boot from an USB stick (what was that he wanted), and installed Kali Linux on two empty partitions earmarked for that.

Now, when the Laptop is booted, the BIOS screen appears.

Not even windoze 10 boots.

Within the BIOS there is no option displayed to remove EFI boot entries.
So I guess there aren’t left any.
Or the EFI boot partition is broken.

Using GParted from a life Linux brings out, that all the 9 partitions (from EFI boot partition, windows partitions, openSUSE root and home, swap, Kali root and home) do still exist, so the partition table still is OK!

I tried: “Boot your machine from the installation media. In the boot screen, choose More › Boot Linux System.”, as described in https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/cha.trouble.html

Well, fine, by that way, options to boot openSUSE and Kali are displayed alongside the right partition numbers.
So obviously, the systems present are recognized by the installer/rescue medium. In fact.
But booting them fails. For whatever reasons.

So, what I’m supposed to do?

Should I format the EFI boot partition, because it may be errorneous?
But what to do afterwards?

The text in
https://doc.opensuse.org/documentation/leap/startup/html/book.opensuse.startup/cha.trouble.html#sec.trouble.data.recover.rescue.grub
describing an alternative way to fix this problem for me isn’t helpful, because it leaves out too many details. I’m not a “Guru”.

Is there an easy way to fix that?

Many thanks in advance,
Mike

It’s hard to know what the problem is, given the limited information provided.

One possible guess is that UEFI booting has been disabled in BIOS settings.

In order to fix UEFI booting, you have to be booted into EFI mode.

I suggest you start with attempting to boot the installer or the live Leap 15 into EFI mode. If you still have the original installer, see if you can boot that in EFI mode to the rescue system. Otherwise, try booting the live system which you can download from HERE.

As a test of whether you are booted to EFI mode, try using the command:

efibootmgr -v

(you might need to be root to run that).

If it gives an error message about “efivars” then you are not booted in EFI mode.

Report back, and that will give us a starting point toward fixing.

1 Like

Hi nrickert!

Thank you very much for your reply and your input.

I instantly found it logical to check whether the laptop is booted in UEFI mode.

I first had a look at the BIOS settings but found no clue.

I plugged an USB stick with MBR and legacy boot of openSUSE 42.3 which I once installed on (in order to have the possibility to boot a working system from an external device) from which I can boot well on other PCs I have.
But after power on I immediately end up in the BIOS setting again.
Just like it happens when I power on the laptop without any USB stick plugged (see 1st posting).

So

isn’t possible that way.

Different situation if I boot from the openSUSE 15.0 installer DVD “burned” to another USB stick.
I choose “install”.
After the Kernel and the installer loaded, I press Ctrl-Alt-F9 and get a root console.

Sorry, clicked on the wrong button (not preview post, reason for edtit), and will continue in a few minutes in another post.

OK after booting from the openSUSE 15.0 installer “DVD” on the USB stick and Ctrl-Alt-F9 I have a root prompt and enter “efibootmgr -v”, as you suggested.
I did that two times.
One time I get (I had to type that by hand)


#tty9:install:/ # efibootmgr -v
Timeout: 1 seconds
No BootOrder is set; firmware will attempt recovery
#tty9:install:/ # 

The other time


#tty9:install:/ # efibootmgr -v
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001
Boot0001* UEFI: Intenso Rainbow 0.00, Partition 1   PciRoot(0x0)/Pci(0x14,0x0)/USB(0,0)/HD(1,MBR,0x6b8b4567,0xa30,0x1e84)..BO
#tty9:install:/ # 

Another thing I did there was to enter “parted -l”.
I would only type and post the whole output if it is really necessary, since I don’t seem to have a bootable and writable USB stick at the moment, so copy and paste currently doesn’t work for me on that laptop.
From this “parted -l” I get:


partition table: gpt
Disk Flags: pmbr_boot

Along that I learned from that “parted -l”:
the openSUSE root partition has the flag


legacy_boot

I interviewed my son again, and it seems that he did something really nasty: After booting openSUSE 15.0 from the laptop (which then still worked fine), in YaST > bootloader he changed GRUB2-EFI to GRUB2, not recognising that the changes would take effect on the HDD instead of the USB key on which he wanted to rearrange things …

That would fit well to the fact that the laptop refuses to boot from the USB stick with MBR and legacy boot.

Besides, the laptop is a F751S. Sorry that I didn’t give that information earlier.

Additional remarks:

I can run GParted from a live Kali-Linux if that would help (to e.g. change flags or whatever).

Reinstalling openSUSE 15.0 wouldn’t cause me that much pain - I would do it if that would help, only I wonder what could be done with respect to the entry of windoze 10 in the UEFI boot partition - GParted of that live Kali-Linux tells that there are about 30MB of data in that partition.

Okay.

Firstly, my mistake. I should have suggested CTRL-ALT-F2 to get a terminal where you can enter that “efibootmgr -v” command. Actually, I did suggest booting it to the rescue system, which would have given you a console session.

However, it does seem that you are connecting with UEFI firmware, so reinstalling grub2-efi should work.

The “legacy_boot” flag in the openSUSE partition probably won’t cause any problems.

In any case, here’s how to proceed.

1: Boot the install medium to the rescue system. You should be able to login as root with no password.

2: Mount your root partition at “/mnt”. This will be something like:

mount /dev/sdaX /mnt

but change that to the root partition of your opensuse system.

3: Maybe run

efibootmgr -v

just to check that you are in EFI mode. If it tells you that no boot order is set, that’s okay at this stage. If it reports an error with “efivars” then you are booted to legacy mode.

4: Some bind mounts:


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

5: Now chroot into your mounted system, with

chroot /mnt

6: You should still be in your chroot session. So do:

mount -a

That should mount everything else that you need. Maybe check with:

ls /boot/efi

(it should list something, perhaps “EFI” (a directory name).

7: Install grub2-efi with:

shim-install

And you probably need to update the boot menu, with

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

8: Exit from the chroot session

exit

9: Reboot from command line

shutdown -r now

I’ll note that you might need to have secure-boot disabled for this to work. We can fix that later.

If the Windows boot code is in the EFI partition, then that should be picked up as a boot entry in the grub2 menu.

Let us know how things turn out.

1 Like

Hi nrickert!

Thank you very much for this.

Entering these commands I end up with mixed results.

Almost all seemed to work, and I only changed the last command

shutdown -r now

to

shutdown -h now

in order to be able to unplug the USB stick with the 15.0 installer “DVD” on it before reboot.

And

efibootmgr -v

gave no error about “efivars”, but resulted in a reasonable output (similar to the second output reported above).

One warning occurred (typed by hand from the photos that I took):


rescue:/ #
rescue:/ # grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.12.14-lp150.12.25-default
Found initrd image: /boot/initrd-4.12.14-lp150.12.25-default
Found linux image: /boot/vmlinuz-4.12.14-lp150.12.13-default
Found initrd image: /boot/initrd-4.12.14-lp150.12.13-default
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
done
rescue:/ #

But after unplugging the USB stick after “shutdown -h now” and subsequent power on, I immediately end up in the BIOS setup again, instead of GRUB2-EFI.

I plug the USB stick with the 15.0 installer “DVD” again, reboot, then “parted -l”: the openSUSE 15.0 root partition on the HDD still has the flag “legacy_boot” set.
May that be the reason that the laptop refuses to boot from the HDD?
But why isn’t GRUB2-EFI ran, even if it might not work properly?

Should I try to reinstall openSUSE 15.0?
Or should I use GParted from the Kali-Linux live medium to remove that “legacy_boot” flag of the openSUSE 15.0 root partition on the HDD?

Many thanks again
Mike

Of course!

I know very well that things on the forums aren’t always easy.

:slight_smile:

I doubt that the legacy_boot flag is a problem. I have not come across cases of that. However, you might check whether the “pmbr_boot” flag is set. There have been case where that has caused problems.

You can google “pmbr_boot” for more information and for hints on how to clear that flag.

The “pmbr_boot” flag was set for the internal HDD of that laptop.
See posting #4 of this thread.

And it is still set, I just verified that using “parted -l” after booting the rescue system from the openSUSE 15.0 installer.

Then you need to clear that flag.

You can use “parted” to do that, but the documentation might not describe how.

Google for

toggle pmbr_boot

Once you have cleared that flag, it may start to work properly.

Maybe that was it:

I just removed that “pmbr_boot” flag following:
https://lists.opensuse.org/opensuse-bugs/2015-05/msg01813.html

Now the laptop obviously boots from the HDD into Windoze.

And the rest of it will be much easier.

Thank you very much nrickert for your help!

Mike

1 Like