Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Bizarre Grub bootloader issues

Linux Kernel, Network, and Services configuration.
Message
Author
adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

[Solved] Bizarre Grub bootloader issues

#1 Post by adrit123 »

I've been having this problem recently on my debian bullseye installation where in some instances, the grub rescue menu would show up instead of the usual grub. I have used multiple tutorials: https://www.linuxfoundation.org/blog/bl ... 2-on-linux, https://phoenixnap.com/kb/grub-rescue and https://youtu.be/r7meKJsjqfY to try fixing the issue but none seem to work as important commands like the insmod and setting root/loading the kernel all seem to fail(shown in the screenshots). The bizarre thing about this issue is also the fact that it doesn't always happens, perhaps it happens maybe 4 out of 10 times I boot up my system and after failing to solve it through the tutorial methods, I've found that simply restarting my computer once the rescue screen shows up seems to have a chance of making it go away and to load the correct grub. For context, my computer is a dual boot system with windows and now debian on 2 separate hard drives(the one debian resides in is hd0) with an efi partition on each. When I used manjaro a while ago, I installed it the same way as I installed debian and yet only debian seems to have this issue. I am at my wit's end on any solutions as I cannot find any problems similar to mine online and I do not want to give up on debian yet as I am loving it, but it makes me very nervous that my system could suddenly not just boot while I need it for an emergency. I hope I do not have to go back to manjaro/arch again.**inxi + neofetch information screenshots and my grub rescue attempt shown below**
Attachments
IMG_3750.jpg
Screenshot from 2023-01-04 01-36-46.png
Screenshot from 2023-01-04 01-36-55.png
Last edited by adrit123 on 2023-01-09 03:24, edited 3 times in total.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#2 Post by p.H »

adrit123 wrote: 2023-01-03 19:41 the grub rescue menu would show up instead of the usual grub
What do you mean by "grub rescue menu" ? What happens exactly ?
The screenshot does not show any grub rescue shell nor menu, only the normal grub shell.

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#3 Post by adrit123 »

p.H wrote: 2023-01-03 23:22
adrit123 wrote: 2023-01-03 19:41 the grub rescue menu would show up instead of the usual grub
What do you mean by "grub rescue menu" ? What happens exactly ?
The screenshot does not show any grub rescue shell nor menu, only the normal grub shell.
When I boot up my computer sometimes the normal grub shows up but other times the grub shell rescue as shown in the first screenshot appears instead. It is bizarre because it doesn't always happen and yet it does and my solution thus far has always been to restart the computer until the normal grub shows up, I know it is not a permanent solution but I don't know what the problem is.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#4 Post by p.H »

adrit123 wrote: 2023-01-04 04:25 the grub shell rescue as shown in the first screenshot appears instead
You are only repeating without providing more information instead of describing exactly what happens on the screen before you typed anything. So I will repeat too: the screenshot does not show a GRUB rescue shell, so your description is inaccurate. The GRUB rescue shell would print the prompt "grub rescue>" instead of the normal prompt "grub>". Also the rescue shell would not have a graphic background picture, unless you manually reverted from normal mode to rescue mode with the command "normal_exit".

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#5 Post by adrit123 »

p.H wrote: 2023-01-04 07:37
adrit123 wrote: 2023-01-04 04:25 the grub shell rescue as shown in the first screenshot appears instead
You are only repeating without providing more information instead of describing exactly what happens on the screen before you typed anything. So I will repeat too: the screenshot does not show a GRUB rescue shell, so your description is inaccurate. The GRUB rescue shell would print the prompt "grub rescue>" instead of the normal prompt "grub>". Also the rescue shell would not have a graphic background picture, unless you manually reverted from normal mode to rescue mode with the command "normal_exit".
Oh, sorry about that I did not know there was a difference as the tutorials I watched to fix the issue all refer it is a "grub rescue". Regardless by your description it is not a grub rescue shell as there is no grub rescue> in the prompt however the text on top says "Minimal bash line scripting is supported" similar to the tutorials I linked. To provide more information, I will attach photos of my lsblk information. For context, my windows is installed on the nvme drive, while debian is on the sda drive. Each drive has an efi system partition(nvme's is nvme0n1) while the sda's is /dev/sda1 which is where grub is installed, however I did notice that /dev/sda1 is not mounted by default.
Attachments
Screenshot from 2023-01-04 14-32-33.png
Screenshot from 2023-01-04 14-37-03.png
Last edited by adrit123 on 2023-01-04 08:59, edited 3 times in total.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#6 Post by p.H »

/tmp should not be used as a temporary mount point. Use /mnt instead.

Can you post plain text from the console by copy and paste instead of screenshots ?

/dev/sda1 instead of /dev/nvme0n1p1 should be mounted on /boot/efi. Compare /etc/fstab and the output of blkid. Mounting the wrong EFI partition on /boot/efi does not disrupt the boot process (it does not even have to be mounted for normal operation) but it will cause trouble when reinstalling GRUB after a package update.

When GRUB boots normally and displays the menu, press "c" to launch the shell, run "set" and note the values of $cmdpath and $prefix.

When GRUB does not boot normally and lauches the shell by itself, do the same and compare with the previous values.
If $prefix is different, set it to the exact same value.
Run

Code: Select all

configfile $prefix/grub.cfg
Last edited by p.H on 2023-01-04 19:46, edited 1 time in total.

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#7 Post by adrit123 »

p.H wrote: 2023-01-04 13:31 /tmp should not be used as a temporary mount point. Use /mnt instead.

Can you post plain text from the console by copy and paste instead of screenshots ?

/dev/sda1 instead of /dev/nvme0n1p1 should be mounted on /boot/efi. Compare /etc/fstab and the output of blkid. Mounting the wrong EFI partition on /boot/efi does not disrupt the boot process (it does not even have to be mounted for normal operation) but it will cause trouble when reinstalling GRUB after a package update.

When GRUB boots normally and displays the menu, press "c" to launch the shell, run "set" and note the values of $cmdpath and $prefix.

When GRUB does not boot normally and lauches the shell by itself, do the same and compare with the previous values.
If $prefix is different, set it to the exact same value.
Run

Code: Select all

source $prefix/grub.cfg
I have edited my /etc/fstab to mount /dev/sda1 on /boot/efi:

Code: Select all

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 476.9G  0 disk 
├─sda1        8:1    0   476M  0 part /boot/efi
├─sda2        8:2    0  14.9G  0 part [SWAP]
├─sda3        8:3    0 279.4G  0 part /home
└─sda4        8:4    0 111.8G  0 part /
nvme0n1     259:0    0 476.9G  0 disk 
├─nvme0n1p1 259:1    0   250M  0 part 
├─nvme0n1p2 259:2    0   128M  0 part 
├─nvme0n1p3 259:3    0   308G  0 part 
├─nvme0n1p4 259:4    0    50G  0 part 
├─nvme0n1p5 259:5    0   990M  0 part 
├─nvme0n1p6 259:6    0    16G  0 part 
└─nvme0n1p7 259:7    0   1.5G  0 part
I have also run set on GRUB both when it boots normally and also when only the shell shows up, in particular the cmd path and prefix have the same values however I did notice that some other values for the grub shell were different. Attached are pictures of both cases, since I'm not sure how to copy paste the text from there. I also tried to see if perhaps there was a leftover grub from a previous linux ubuntu installation in the nvme efi partition's EFI/Boot with

Code: Select all

objdump --section=.sbat --full-contents bootx64.efi
which outputs:

Code: Select all

Contents of section .sbat:
 d3000 73626174 2c312c53 42415420 56657273  sbat,1,SBAT Vers
 d3010 696f6e2c 73626174 2c312c68 74747073  ion,sbat,1,https
 d3020 3a2f2f67 69746875 622e636f 6d2f7268  ://github.com/rh
 d3030 626f6f74 2f736869 6d2f626c 6f622f6d  boot/shim/blob/m
 d3040 61696e2f 53424154 2e6d640a 7368696d  ain/SBAT.md.shim
 d3050 2c312c55 45464920 7368696d 2c736869  ,1,UEFI shim,shi
 d3060 6d2c312c 68747470 733a2f2f 67697468  m,1,https://gith
 d3070 75622e63 6f6d2f72 68626f6f 742f7368  ub.com/rhboot/sh
 d3080 696d0a73 68696d2e 7562756e 74752c31  im.shim.ubuntu,1
 d3090 2c556275 6e74752c 7368696d 2c31352e  ,Ubuntu,shim,15.
 d30a0 342d3075 62756e74 75392c68 74747073  4-0ubuntu9,https
 d30b0 3a2f2f77 77772e75 62756e74 752e636f  ://www.ubuntu.co
 d30c0 6d2f0a          
I am not sure what to make of it but it appears that ubuntu still exists?
Attachments
image1.jpg
image0.jpg
Last edited by adrit123 on 2023-01-04 15:28, edited 1 time in total.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#8 Post by p.H »

image1.jpg shows the expected output when GRUB did not load its main config file /boot/grub/grub.cfg : default font, no background picture, black background. The only unusual part is the line "error: Command failed." after the output of "set".

Conversely, image0.jpg shows the expected output when GRUB loaded the standard main config file : unicode font, background picture. There are more environment variables because the new ones are created by the config file.

The screenshot in the original post puzzles me because it shows a background picture and text in unicode font as if the config file was loaded, but not the new variables and values set by it.

Suggesting to using the "source" command was a mistake because it won't show the menu even if the file is successfully loaded. The "configfile" command should be used instead. Also you can type some commands to check the config file can be read :

Code: Select all

ls $prefix/
cat $prefix/grub.cfg
I do not think that the remaining Ubuntu files in the EFI partition of the NVMe SSD is relevant here, because it is always Debian's GRUB which is launched.

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#9 Post by adrit123 »

The ls $prefix/ command shows:

Code: Select all

x_86_64-efi/ locale/ fonts/ unicode.pf2 grubenv grub.cfg
I have also attached a pastebin of the results of the bootinfoscript which includes the information shown by the $prefix/grub.cfg and more: app.php/pastebin/?mode=view&s=11.
From asking other forums, I have been told that the reason behind this problem could be due to having 2 EFI partitions on separate disks, causing bios to be confused as it randomly loads one on every boot, in this case would I need to delete one of the partitions and move grub to the other one? I also have to mention that when I first installed debian with the unofficial live cd version, I did not know about booting the live cd in uefi mode, so could that also be a source of error?

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#10 Post by adrit123 »

After deleting the efi partition from the /dev/sda drive, the stubborn issue still persists, I do not know what the problem is but I am wondering if it could be due to the way the system was installed or perhaps debian itself does not work well on my hardware.

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#11 Post by adrit123 »

adrit123 wrote: 2023-01-05 11:04 After deleting the efi partition from the /dev/sda drive, the stubborn issue still persists, I do not know what the problem is but I am wondering if it could be due to the way the system was installed or perhaps debian itself does not work well on my hardware.
Update to the situation: With the suggestions of some forums, I moved back grub and all the bootloader information back to the nvme0n1 drive and deleted the efi partition on the sda drive to ensure only one efi partition exists across both drives. However, the issue still persists. The good news is I have made a new discovery, when the shell screen shows up, I found out that if I typed "exit" the usual grub screen will pop up and the shell prompt will exit. This has brought me a little relief but the shell popping up in the first place at random still is an issue.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#12 Post by p.H »

adrit123 wrote: 2023-01-05 05:39 The ls $prefix/ command shows:
It shows grub.cfg, so what about the next suggested commands (cat and configfile on $prefix/grub.cfg) or "normal" ?

I do not see anything suspicious in the bootinfoscript report.
It was unlikely that the dual EFI partitions caused the issue. All available information show that GRUB is launched from the correct location.
adrit123 wrote: 2023-01-05 11:38 found out that if I typed "exit" the usual grub screen will pop up
The GRUB menu ? "exit" terminates GRUB, and the UEFI firmware selects another boot loader. It is a bit weird that GRUB is selected again. What is the output of "efibootmgr -v" in Debian ?

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#13 Post by adrit123 »

p.H wrote: 2023-01-05 22:26
adrit123 wrote: 2023-01-05 05:39 The ls $prefix/ command shows:
It shows grub.cfg, so what about the next suggested commands (cat and configfile on $prefix/grub.cfg) or "normal" ?

I do not see anything suspicious in the bootinfoscript report.
It was unlikely that the dual EFI partitions caused the issue. All available information show that GRUB is launched from the correct location.
adrit123 wrote: 2023-01-05 11:38 found out that if I typed "exit" the usual grub screen will pop up
The GRUB menu ? "exit" terminates GRUB, and the UEFI firmware selects another boot loader. It is a bit weird that GRUB is selected again. What is the output of "efibootmgr -v" in Debian ?
Efibootmgr -v displays:

Code: Select all

BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0002,0000
Boot0000* UEFI BC511 NVMe SK hynix 512GB CN05N917313305T0E 1	PciRoot(0x0)/Pci(0x1d,0x4)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)/HD(1,GPT,68fb3aaf-45e8-4bbd-bb44-87c445b9b84c,0x800,0x7d000)/File(\EFI\Boot\BootX64.efi)N.....YM....R,Y.
Boot0001* debian	HD(1,GPT,68fb3aaf-45e8-4bbd-bb44-87c445b9b84c,0x800,0x7d000)/File(EFI\debian\grubx64.efi)
Boot0002* Windows Boot Manager	HD(1,GPT,68fb3aaf-45e8-4bbd-bb44-87c445b9b84c,0x800,0x7d000)/File(\Efi\debian\grubx64.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
As for the other commands, when the black grub shell pops up, the command cannot be run at all instead showing "command failed", meanwhile on the debian grub with the background, it shows the grub menu entries in detail. Normal on the black grub shell appears to do nothing except clear all the commands and showing a new grub prompt.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#14 Post by p.H »

The next boot entry ("Windows boot manager") also points to /efi/debian/grubx64.efi, this explains why GRUB is run again after exit.
However the Debian and Windows boot entries are not normal. The Debian entry should point to /efi/debian/shimx64.efi if grub-efi-amd64-signed and shim-signed arer installed, which is the default, and the Windows entry should point to /efi/microsoft/boot/bootmgfw.efi. Did you mess with EFI boot entries and/or bcdedit under Windows ?

PS. Please do not quote the whole previous post, it is useless and wastes space.

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#15 Post by adrit123 »

Yes i did edit the efi boot entry for debian and changed the bcdedit boot order for the windows boot entry. How should I change them to be correct?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Bizarre Grub bootloader issues

#16 Post by p.H »

Note that using grubx64.efi in boot entries won't work if secure boot is enabled unless you added Debian's key to the firmware allowed list. grubx64.efi is signed with Debian's key so boot entries must point to shimx64.efi which is signed with Microsoft's key, the only one allowed by most UEFI firmwares by default. Then shimx64.efi will load grubx64.efi and check Debians's signature. If secure boot is disabled you do not have to bother about it, booting directly with grubx64.efi should work fine.

I guess you can restore the original boot entry for Windows with bcdedit. It will make Windows bootable on its own again without going through the GRUB menu.
You can re-create the proper boot entry for Debian by reinstalling GRUB with "grub-install" (no argument needed).
However I am afraid that neither will fix the issue, and "exit" will not relaunch GRUB any more but launch Windows instead. As for the issue, I have never seen this error message when executing correct commands and have no clue. Just a wild guess, I have seen weird issues caused by the tpm module, so it may be worth a try to remove it and retry to load the menu.

Code: Select all

rmmod tpm
configfile /boot/grub/grub.cfg

adrit123
Posts: 10
Joined: 2023-01-03 19:31
Has thanked: 2 times

Re: Bizarre Grub bootloader issues

#17 Post by adrit123 »

I typed in rmmod tpm and the configfile commands when the black grub prompt boots up and it changes it to the normal grub, however afterwards I discovered that it may have potentially caused issues such as my wifi to stop working. At this point, I believe Debian on my laptop is far more trouble than its worth and will switch back to either Manjaro or Arch linux. Nonetheless, thank you for being patient and helping me with my problems even if it wasn't fully solved in the end.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: [Solved] Bizarre Grub bootloader issues

#18 Post by p.H »

I do not see how disabling the tpm module in GRUB would affect the wifi. Maybe the root cause affects both GRUB and the wifi.
If the laptop is very recent (less than ~2 years), maybe Debian stable is too old for it.
You could try installing Arch/Manjaro in dual boot with Arch GRUB as the primary boot loader and test whether
- Arch GRUB has the same issue
- Debian has the wifi issue when booting it from Arch GRUB

tane
Posts: 8
Joined: 2023-01-28 18:24

Re: [Solved] Bizarre Grub bootloader issues

#19 Post by tane »

I have this same issue.

It has been a long chaotic couple of days of trying to solve it and I think it might be a bios issue. Bios is picking up bootmgfw.efi, shimx64.efi and grub64.efi. If you set the entry (say grub64.efi) in the bios it will boot to a normal grub screen and all is well, but on reboot it quite often drops to grubs command line. It is almost like it is rearranging the boot entries (which are both named the same on the bios screen) after boot. Weirdly I have fairly much the same setup as the original poster (1 nvme with w11 on it and an ssd with debian 11 on it). I have had the same problem with efi partitions on both disks and have resorted to using the w11 efi partition but to no avail. I don't use secure boot, although I activated it at one point to see whether I could get it to stick to using shimx64.efi but to no avail.

Personally, I would like to delete shimx64.efi but I haven't been able to find any reference to the effects and that is a little blunt.

Next step is to load D11 using the W11 bootloader and spent some time with my family. :D

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: [Solved] Bizarre Grub bootloader issues

#20 Post by p.H »

tane wrote: 2023-01-28 18:52 Bios is picking up bootmgfw.efi, shimx64.efi and grub64.efi
What do you mean by "picking up" ?
tane wrote: 2023-01-28 18:52 If you set the entry (say grub64.efi) in the bios
What do you mean by "set the entry in the BIOS" ?

Can you post the output of

Code: Select all

efibootmgr -v
tane wrote: 2023-01-28 18:52 I would like to delete shimx64.efi but I haven't been able to find any reference to the effects
If you suspect shim is the culprit, you can wipe /boot/efi/EFI/debian and reinstall GRUB without shim with

Code: Select all

grub-install --no-uefi-secure-boot
Of course secure boot must be disabled. Only shim can be loaded by the UEFI firmware when secure boot is enabled, and will then load GRUB.
Or you can delete shimx64.efi, delete the EFI boot entry which points to it and replace it with a boot entry pointing to grubx64.efi.
Or rename/move it and replace it with a copy of grubx64.efi renamed as shimx64.efi.

Post Reply