Bug 13901 - rescue mode reinstall bootloader fail unknown method install_raw_grub2
Summary: rescue mode reinstall bootloader fail unknown method install_raw_grub2
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: Installer (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: release_blocker major
Target Milestone: ---
Assignee: Thierry Vignaud
QA Contact:
URL:
Whiteboard: 5alpha2
Keywords: NEEDINFO
Depends on:
Blocks: 416 14069
  Show dependency treegraph
 
Reported: 2014-08-12 21:33 CEST by Tony Blackwell
Modified: 2015-04-14 17:01 CEST (History)
6 users (show)

See Also:
Source RPM: drakx-installer-rescue
CVE:
Status comment:


Attachments
screen photo (459.45 KB, image/jpeg)
2015-04-06 21:26 CEST, Samuel Verschelde
Details

Description Tony Blackwell 2014-08-12 21:33:30 CEST
Hardware: UEFI laptop, dual RAID 0 SSD's.

Classic M5a2 x86_64 DVD UEFI-booted in rescue mode.  Attempting to use the menu option for reinstalling bootloader correctly starts:

find_root_parts found md126p7: Mageia (Cauldron) for x86_64
--> Selecting /dev/md126p7 as root fs
Mounting other partitions from fstab on /mnt...
UUID=1887-3A79 on /mnt/boot/efi type vfat options defaults
Your system is ready on /mnt.

then fails with
unknown bootloader method install_raw_grub2
Tony Blackwell 2014-08-12 21:36:59 CEST

Whiteboard: (none) => mageia 5 alpha 2
Severity: normal => major

Comment 1 Marja Van Waes 2014-08-13 22:08:47 CEST
AFAIK, reinstalling the bootloader from the classical installer rescue menu-entry has never worked for grub2 (neither for EFI, nor for non-EFI systems).

We may have forgotten to document that, though :-/

IIRC, barjac advised to use Super Grub2 Disk to boot into an otherwise unbootable Mageia, and then repair the bootloader.

cc'ing him

CC: (none) => marja11, zen25000
Hardware: i586 => All

Comment 2 Tony Blackwell 2014-08-13 23:43:47 CEST
Thanks for the comment Marja,
Sorry, I don't know about the Super Grub2 Disk.  Where do I download this from?
Comment 3 Barry Jackson 2014-08-14 00:33:08 CEST
http://www.supergrubdisk.org/super-grub2-disk/
Manuel Hiebel 2014-08-19 22:50:00 CEST

Blocks: (none) => 416

Comment 4 Tony Blackwell 2014-08-20 07:33:43 CEST
Super Grub2 unable to reinstall bootloader
Comment 5 Barry Jackson 2014-08-20 12:41:09 CEST
(In reply to Tony Blackwell from comment #4)
> Super Grub2 unable to reinstall bootloader

It may be worth having a chat with Jordan_U on Freenode #grub. He is a grub2 dev and iirc authors the supergrub2 isos.
Comment 6 Tony Blackwell 2014-08-20 13:10:30 CEST
Appreciate the suggestion.  I'm a day from going to spend 3 weeks out-of-touch in the Desert in central Australia, so my lack of response in coming weeks is not lack of interest!  Will take it further as soon as I get back.
Tonyb
Comment 7 Dick Gevers 2014-11-24 22:14:18 CET
@tablackwell: in #c6 you wrote on 2014-08-20:

> Will take it further as soon as I get back.

Keywords: (none) => NEEDINFO
Whiteboard: mageia 5 alpha 2 => 5alpha2

Comment 8 Thierry Vignaud 2015-02-18 17:18:58 CET
I should really generate a /boot/grub2/install.sh and introduce install_raw_grub2() to run it

CC: (none) => thierry.vignaud
Assignee: bugsquad => thierry.vignaud

Comment 9 Mageia Robot 2015-04-03 18:20:56 CEST
commit df8433f2db7142b045a80391b74c21057a92b2d3
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Fri Apr 3 18:17:58 2015 +0200

    split install_raw_grub2() out of install_grub2()
    
    thus fixing grub2 rescue (mga#13408, mga#13901)
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=df8433f2db7142b045a80391b74c21057a92b2d3

 Bug links:
   Mageia
      https://bugs.mageia.org/13408
      https://bugs.mageia.org/13901
Samuel Verschelde 2015-04-03 21:53:48 CEST

CC: (none) => stormi

Comment 10 Samuel Verschelde 2015-04-06 21:25:15 CEST
The error message about grub2 is now gone (tested with recent boot-nonfree.iso), but it fails afterwards for me. Adding it as follow-up to this report considering the message doesn't suggest a specific issue. If I'm wrong and it works for others I will open a new report.

Error message:

Error: <grub2-install: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't exist. Please specify --target or --directory

See attached picture.
Comment 11 Samuel Verschelde 2015-04-06 21:26:00 CEST
Created attachment 6202 [details]
screen photo
Samuel Verschelde 2015-04-06 23:04:47 CEST

Keywords: NEEDINFO => (none)

Comment 12 Samuel Verschelde 2015-04-07 10:49:25 CEST
Setting release blocker since now grub2 is mandatory for UEFI so it's more likely people try to use rescue to reinstall grub2 bootloader.

Priority: Normal => release_blocker
Blocks: (none) => 14069

Comment 13 Thierry Vignaud 2015-04-07 11:15:54 CEST
There was a regression that was tracked in bug #15640
Please wait for drakxtools to be uploaded by Thomas or Anne then for drakx-installer-rescue to be rebuild
William Kenney 2015-04-07 19:37:12 CEST

CC: (none) => wilcal.int

Comment 14 Thierry Vignaud 2015-04-08 09:36:44 CEST
You can try again with last evening rescue.
install/stage2/rescue.sqfs must be dated from "07-Apr-2015 20:09".
eg:
http://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia//distrib/cauldron/x86_64/install/stage2/

Keywords: (none) => NEEDINFO

Thierry Vignaud 2015-04-08 11:59:19 CEST

Source RPM: (none) => drakx-installer-rescue

Comment 15 Mageia Robot 2015-04-09 17:45:21 CEST
commit 6a38c077285c88dcf4d042ec43b6803ba5c56cb1
Author: Thierry Vignaud <thierry.vignaud@...>
Date:   Wed Apr 8 05:53:19 2015 -0400

    fix detecting grub2 on ESP
    
    We only support detecting grub2 on ESP for now.
    This might help mga#13901
    
    fix:
    $ detectloader
    Cannot find a boot loader installed
---
 Commit Link:
   http://gitweb.mageia.org/software/drakx/commit/?id=6a38c077285c88dcf4d042ec43b6803ba5c56cb1
Comment 16 Thierry Vignaud 2015-04-09 19:31:46 CEST
Please try again with the rescue that will land in a couple hours on mirrors
Comment 17 Samuel Verschelde 2015-04-09 23:51:06 CEST
I just tried, making sure to use distrib-coffee, and the mirror's current rescue.sqfs is dated 09-Apr-2015 19:32

It did more things, but still failed, now with the following message:

sh: /boot/grub2/install.sh: No such file or directory
Samuel Verschelde 2015-04-09 23:51:13 CEST

Keywords: NEEDINFO => (none)

Comment 18 Thierry Vignaud 2015-04-10 06:01:53 CEST
That's b/c you hadn't first reconfigure it with latest drakboot.
We now write a /boot/grub2/install.sh like for grub, but of course, previous install don't have it

Keywords: (none) => NEEDINFO

Comment 19 Samuel Verschelde 2015-04-10 10:30:44 CEST
Thanks for the precision. We'll maybe have to add in errata that it won't work for a grub2 installed from an older mga release.
Comment 20 Tony Blackwell 2015-04-11 01:25:14 CEST
I'm still testing this but BIOS issues re laptop RAID delaying me and time is very short, so I'd be happy to see a note in errata re this, and close this bug.
Comment 21 Thierry Vignaud 2015-04-13 14:59:34 CEST
(In reply to Samuel VERSCHELDE from comment #10)
> Error: <grub2-install: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't
> exist. Please specify --target or --directory

That's because you installed grub2-efi on a !UEFI machine.
Or that you disabled UEFI in either firmware or VBox....
Comment 22 Samuel Verschelde 2015-04-13 15:10:32 CEST
(In reply to Thierry Vignaud from comment #21)
> (In reply to Samuel VERSCHELDE from comment #10)
> > Error: <grub2-install: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't
> > exist. Please specify --target or --directory
> 
> That's because you installed grub2-efi on a !UEFI machine.
> Or that you disabled UEFI in either firmware or VBox....

Well, the installation was made in UEFI mode and the boot-nonfree ISO from which I started rescue was copied (not dumped with dd) to the USB key and booted in UEFI mode so it's all UEFI for me. But I haven't got this error message with recent rescue.sqfs.

Now I have to test according to comment #18, first reinstalling so that install.sh is created, then rescueing.
Rémi Verschelde 2015-04-13 16:45:47 CEST

CC: (none) => rverschelde

Comment 23 Samuel Verschelde 2015-04-13 19:18:47 CEST
(In reply to Thierry Vignaud from comment #18)
> That's b/c you hadn't first reconfigure it with latest drakboot.
> We now write a /boot/grub2/install.sh like for grub, but of course, previous
> install don't have it

New tests, new results!

So, now I have no more errors. I boot in rescue mode from boot-nonfree.iso, UEFI, select dc as a mirror, and choose the "restore bootloader" option. Then I select my mga5 system (which was installed in UEFI mode, with grub2-efi), and everything goes fine (except that it lacks a "your bootloader has been restored" success dialog and goes back to the menu).

But, sadly, the Mageia boot entry is not made available: the only available option according to my UEFI "bios-like" menu for that disk is the windows system. I must stress that after the bootloader installation from the classical install in UEFI mode, that mageia entry does appear, so it looks like there's something different with what the rescue mode does. 

I understand that every firmware is different, so here is some background about my computer:
* fast boot and secure boot disabled, of course
* it offers a global switch between an UEFI mode and a Legacy boot mode.
* in UEFI mode, you must, in the setup, select which bootloader you want to start by default: either windows or mageia. After installing mageia, it is not automatically made the default, I have to do that manually in the firmware's boot setup. I don't know if I'm alone in that case and if there's something that can be done at Mageia's installer level or not.

Knowing this, here is what I do:
* Switch to UEFI
* Boot the boot-nonfree ISO in UEFI mode (I'm sure it is in UEFI mode because in that mode my computer won't boot any device in legacy mode, and I made sure to format it as vfat and copy the contents of the ISO to it)
* Install Mageia (network install)
* Remove key and Reboot
* Go to UEFI setup screen (F2)
* In boot options, see that there are now 2 options, the former Windows bootloader option, still the default, and a new one called "mageia". Put mageia as the first option.
* Save and exit setup
* Boot Mageia, everything fine

Now, in order to test rescue mode:
* Reboot
* Switch to Legacy mode
* Switch back to UEFI mode
* See that the mageia boot option has disappeared (although, I've checked, I still have a "mageia" directory in the EFI boot partition, I thought that was enough but it apparently isn't)
* Boot the USB stick again
* Select rescue mode, etc., and make it restore the bootloader
* After (apparent) success, reboot
* Enter UEFI setup (F2)
* No "mageia" boot entry available :'(

The fastest way I have to actually restore the boot entry is to start another install, and select "Update mageia 5"... Then it will manage to truly restore it.
Comment 24 Marja Van Waes 2015-04-14 00:13:08 CEST
After deliberately breaking my grub2-efi bootloader, by removing the external HDs I had made my last install on, and after checking I'm indeed dropped to a grub2 emergency shell, using drakx-installer-rescue works fine.

It reinstalls the bootloader from the partition I select, and after that I can reboot fine into Mageia again
Comment 25 Samuel Verschelde 2015-04-14 00:18:03 CEST
Thanks marja for the test. This means this bootloader restore use case is covered, with success. We now need to investigate the failure to write the bootloader bits to NVRAM in rescue mode (my comment #23), as discussed during council meeting with tmb. He talked about either efibootmgr that fails or that is not called for some reason.
Comment 26 Marja Van Waes 2015-04-14 10:53:28 CEST
(In reply to Samuel VERSCHELDE from comment #25)
> Thanks marja for the test. This means this bootloader restore use case is
> covered, with success. We now need to investigate the failure to write the
> bootloader bits to NVRAM in rescue mode (my comment #23), as discussed
> during council meeting with tmb. He talked about either efibootmgr that
> fails or that is not called for some reason.

I could reproduce that, even if switching to legacy mode and back didn't work here to make the Mageia bootloader disappear.

However, running "efibootmgr -O" did the job fine. After that in the UEFI 10 boot choices were visible, but Mageia had disappeared.

This time, using drakx-installer-rescue, everything seemed to go exactly as in my earlier test. However, on reboot I still got the Windows bootloader. In the UEFI, the boot order list was exactly the same as before, with Mageia still missing.
Samuel Verschelde 2015-04-14 10:55:42 CEST

Summary: rescue mode reinstall bootloader fail unknown method install_raw_grub2 => rescue mode fails to reinstall grub2 bootloader in UEFI mode (was: unknown method install_raw_grub2)

Comment 27 Thierry Vignaud 2015-04-14 11:51:13 CEST
Please open a new bug report with info from comments #23 & #25.
The original issue was fixed (crash b/c there was no install_raw_grub2()).
Then a secondary issue was fixed by generating /boot/grub2/install.sh

Let's stop mixing issues, this bug report is already too long.
Thanks

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 28 Marja Van Waes 2015-04-14 17:01:50 CEST
(In reply to Thierry Vignaud from comment #27)
> Please open a new bug report with info from comments #23 & #25.

That became bug 15695

> The original issue was fixed (crash b/c there was no install_raw_grub2()).
> Then a secondary issue was fixed by generating /boot/grub2/install.sh
> 
> Let's stop mixing issues, this bug report is already too long.
> Thanks

Summary: rescue mode fails to reinstall grub2 bootloader in UEFI mode (was: unknown method install_raw_grub2) => rescue mode reinstall bootloader fail unknown method install_raw_grub2


Note You need to log in before you can comment on or make changes to this bug.