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

 

 

 

Helpful tip when grub fails to boot debian

Ask for help with issues regarding the Installations of the Debian O/S.
Post Reply
Message
Author
agrimstad
Posts: 102
Joined: 2007-10-05 00:55
Location: Hollis, NH, USA

Helpful tip when grub fails to boot debian

#1 Post by agrimstad »

I searched the forum and didn't come up with anything quite focused on my need, so I thought it might be helpful to others to post how I fixed my problem.

I installed buster on a clean mirrored hard drive array, which worked fine, and then did an update to bullseye. This looked like it worked, but when I had finished and rebooted, I landed in a grub rescue prompt. Somehow during the upgrade the grub installation was damaged. There are quite a few recipes out there on how to do a grub-install, but none--that I found, at least--quite work for my situation.

My installation used two mirrored hard drives on which I have root and home installed in logical volumes. The recipes I found didn't help with this. Here's what I did to repair grub:

1. Boot from the Debian buster live CD: https://www.debian.org/CD/live/
2. Get access to support for arrays and logical volumes:
$ sudo apt update && sudo apt upgrade
$ sudo apt install mdadm lvm2
3. Assemble my arrays:
$ sudo mdadm --assemble --scan
4. Reinstall grub on my two hard drives:
$ sudo mount /dev/vg0/root /mnt
$ sudo grub-install --root-directory=/mnt -d /mnt/usr/lib/grub/i386-pc /dev/sda
$ sudo grub-install --root-directory=/mnt -d /mnt/usr/lib/grub/i386-pc /dev/sdb

Very simple, but not obvious in the details. That's all.

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

Re: Helpful tip when grub fails to boot debian

#2 Post by p.H »

What was the error message before the grub rescue prompt ?

Did you try to boot from the other (non default) disk ?
If no, during buster installation, did you configure grub-pc to install the boot loader on both disks ? You can check with

Code: Select all

debconf-show grub-pc 2> /dev/null | grep install_device
If no, a possible explanation is as follows :

When upgrading to bullseye, grub-pc postinst script installed the new version of the GRUB boot and core images only on one disk and the computer booted from the other disk still containing the old version of the GRUB boot and core images. Then old core image failed to load modules of the new version installed in /boot/grub due to a version mismatch.

In order to avoid the same issue at the next GRUB package upgrade (this may and did happen even during a stable update), you should reconfigure grub-pc to install the boot loader on both disks with

Code: Select all

dpkg-reconfigure grub-pc
Comments about your repair procedure :

- AFAIK grub-install from current GRUB 2 (grub-pc) has no --root-directory option. This was an option of grub-install from the obsolete GRUB 1 (grub-legacy). Do you mean --boot-directory ? Then you should have specified /mnt/boot instead of /mnt ; otherwise you created a /grub directory at the root instead of /boot/grub.

- IMO, using the Debian installer in rescue mode is simpler that using a live system. The installer assembles RAID arrays and activate LVM logical volumes automatically, offers to mount any volume as root and repair GRUB or start a shell in the volume (chroot). In that shell, you do not need to add -d or --boot-directory options to grub-install.

agrimstad
Posts: 102
Joined: 2007-10-05 00:55
Location: Hollis, NH, USA

Re: Helpful tip when grub fails to boot debian

#3 Post by agrimstad »

Sorry, can't remember the exact diagnostic before the grub repair prompt.

I didn't try to go into the bios to try booting from the other drive. The bios on the particular mobo is sort of hard to use. In any case I always make a point of installing grub on both drives when I do an installation on an array and I did so this time. Buster was booting fine before I did the upgrade to bullseye. Your theory is a possibility, but unlikely in my opinion.

Also, regarding using dpkg-reconfigure grub-pc, note in my little tip I reinstalled grub on both hard drives.

Regarding my grub install options and grub versus grub2, I was using the buster live cd, so I presume it used grub 2. Perhaps the --root-directory wasn't needed, I don't know, I found it on someone else's recipe. (I sort of assume grub needs to know where /boot/grub is and this switch seems to tell it where.) But the -d option was definitely needed. Grub didn't know where to find its files without it.

I take your point on using the installer. I think I've used it in years past to do repairs. It would have been nice to have raid/lvm2 support already installed! I'll try to remember to try it again next disaster.

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

Re: Helpful tip when grub fails to boot debian

#4 Post by p.H »

agrimstad wrote:I always make a point of installing grub on both drives when I do an installation on an array and I did so this time.
How ? At installation time or later with grub-install ?
agrimstad wrote:Also, regarding using dpkg-reconfigure grub-pc, note in my little tip I reinstalled grub on both hard drives.
Using grub-install is not the same as using dpkg-reconfigure grub-pc. Only the latter records the selected boot devices (as can be seen with debconf-show) and will automatically reinstall GRUB on all of them after each grub* package update.

Anyway, it is easy to check with the debconf-show command I provided.

Post Reply