Totally Stumped on Repairing Grub

Four days ago my Grub got corrupted by a Fedora update. I have been all over the WWW trying to find out how to repair Grub. I simply can’t get past errors of “can’t lookup blockdev” and “can’t find in /etc/fstab”.

I am using a freshly downloaded live session .iso of Fedora 43 with KDE Plasma. I am logged in as superuser, using sudo su –

Below are my partition characteristics, compiled from various commands (e.g. lsblk, fdisk -l, etc.). Both drives are internal, I do not have an LVM, there is no Windows on this machine (and no dual boot).


SYSTEM PARTITIONS:
nvme0n1p1 0 .6g vfat efi system
nvme0n1p2 2 g ext4 linux extended boot
nvme0n1p3 293 g btrfs /
nvme0n1p4 62.5g btrfs hibernationswap
nvme0n1p5 573 g btrfs /home

DATA PARTITIONS:
/dev/sda1 through /dev/sda6 (ntfs HDD)

FSTAB (cat /etc/fstab – showing only the nvme drive):
UUID=232a5005-d694-4e4e-b025-9e2e71c50e49 / btrfs subvolid=5 0 0
UUID=c434373b-72fb-4622-bad7-657cf14cd228 /boot ext4 defaults 0 0
UUID=D669-0B52 /boot/efi vfat umask=0077, shortname=winnt 0 2
UUID=2e7bcaef-f294-4542-8df0-e86a508fd150 /home btrfs subvolid=5 0 0
UUID=c45d0e92-381a-450b-9806-02a270560b10 none swap defaults 0 0


For example, this:
mount /dev/nvme0n1p3/boot I get: “can’t lookup blockdev”.

I’ve looked at a couple of dozen online articles on fixing grub, but can’t get past this point. Some things I have tried give a “can’t find in /etc/fstab”, although with Dolphin I can find it when click on the / that (in Properties) is mounted from “/dev/nvme0nip3”, but can’t find it from the / mounted from “LiveOS_roots”.

Hours, and hours wasted. Can you help me?

Why do you think grub is corrupt?

Does you system try to boot then get stuck?
If you are stuck on the splash screen type ESC to see the kernel/startup messages.
What do you see?

That seems wrong why is there /boot at the end of the device path?

2 Likes

Can you show the content of the file /EFI/fedora/grub.cfg inside the EFI partition (i.e. your nvme0n1p1)?

The extra /boot that @barryascott mentions reminds me of a problem another user had with that file recently.

In answer to both replies:

  1. If I try to boot the computer I get three errors that are “../../grub-core/script/lexer.c:352: ”. The X was “syntax error” for the 1st and 3rd, and “incorrect command” for the 2nd one. I can get to a grub> prompt, but was unable to do anything useful from there, so I have been trying live sessions.

  2. As I understand, I need to make three mounts:
    mount /dev/nvme0n1p3 /mnt
    mount /dev/nvme0n1p3 /mnt/boot
    mount /dev/nvme0n1p1 /mnt/boot/efi

  3. I don’t have an /efi in the root of either the nvme drive or the live boot. I do have a
    /boot/efi/EFI/fedora, but it does not have a grub.cfg file. It has a bunch of grub executables, like grub64.efi. The …/fedora directory also has a /boot directory.

And I’m not sure whether I should be trying to mount to /mnt or mnt/…, not knowing where Fedora normally mounts an nvme drive, but all the instructions I have found on fixing grub have those locations, as I have shown them above with my partition designations.

Check cat /proc/cmdline when root=uuid match uuid from fstab and if you check from live usb need to open ‘cmdline ‘ from system

I don’t know how to do that from the ‘system’. I have tried both a regular user and a superuser, and both times I get:
boot_image=(cd0)/boot/x86_64/loader/linux quiet rhgb root=live:cdlabel =fedora=KDE-Live-43 rd.live.image

(Learning Linux the hard way, here.)

From your partition list and your fstab, I would expect that your /boot is actually nvme0n1p2. In your fstab, / and /boot have different UUIDs, so they can’t both be nvme0n1p3.

1 Like

The second nvme0n1p3 line can’t work — you want to use nvme0n1p2 for the boot partition. You should mention where you found the instructions that mount the same partition twice so we try to have them corrected.

1 Like

Those are good hints to pursue. Thanks.

Steep learning curve here. I had saved my system setup with TimeShift, but don’t know how to restore everything with that, in this Live session situation. Is that a way to fix this more easily? And if so, how do I access my actual system to do that, instead of the Live system?

Have you tried Fedora’s official documentation to restore GRUB? You have to replace sdaX with nvme0n1pX, though.

1 Like

I’ll take a look at that later today. Thanks!

I am not really familiar with TimeShift, other than that it is more common in the Ubuntu world and that it requires an Ubuntu-style subvolume layout (@ and @home) for Btrfs snapshots.

Since TimeShift is something users have to setup themselves on Fedora, I doubt people here will be able to assist with, at least not without figuring out how you set it up first.

Hello, I use timeshift on debian-based systems for snapshots (snapper on fedora) and sure, it is an option if it works correctly on fedora. Here it is shown for ubuntu, but the principle is the same: https://ostechnix.com/how-to-backup-and-restore-linux-system-with-timeshift/

But I think you’re almost there even without timeshift:
The lexer.c errors indicate a faulty grub.cfg, which can be fixed like it is described in Fedora’s official documentation with
grub2-mkconfig -o /boot/grub2/grub.cfg

As @l-c-g and @gnwiii pointed out, your /boot partition is nvme0n1p2, not p3. Right now the important thing is to make sure we are actually looking at your installed system and not the LiveOS tree.
From the live session, mount your three Fedora partitions:

mount /dev/nvme0n1p3 /mnt
mount /dev/nvme0n1p2 /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot/efi

The OP is using btrfs. This will not provide the proper paths on fedora since there are 2 subvolumes in that p3 partition.

The command mount /dev/nvme0n1p3 /mnt will result in having both file systems (subvolumes) mounted as /mnt/root and /mnt/home.

Thus the next 2 commands would need altered to
mount /dev/nvme0n1p2 /mnt/root/boot
mount /dev/nvme0n1p1 /mnt/root/boot/efi

Then the installed root / file system would be at /mnt/root

Good catch, thanks for pointing that out.

I’ve only recently started dealing with Btrfs myself. I’ve been running Debian with ext4 for years, so I’m still used to the mindset.

Appreciate the clarification

When you boot your system without live usb press esc to access grub menu with 3 kernels and one rescue select default one first one from list and select button e to edit kernel boot lines there you will see default ‘root=uuid’ check it is match uuid from fstab if not just retype uuid that match it and with ‘ctrl + x’ boot it .

Are you sure about that? In the partition list, nvme0n1p5 is listed as /home. Also, in the fstab shown, the entries for / and /home have different UUIDs and both mount subvolid=5, which would match the partition list (two Btrfs partitions, nvme0n1p3 and nvme0n1p5, at least without actually knowing the UUIDs):

Spearate partitions instead of subvolumes isn’t the default and not how I set up Btrfs systems, but it works. And as /home doesn’t need to be mounted to restore GRUB, I had decided to ignore it.

These two lines also somewhat contradict each other: Is nvme0n1p4 a Btrfs partition, I take it with a swapfile in it, or is it actually a swap partition? A Btrfs partition with a swapfile would get you some of the overhead of Btrfs without any real benefit.

@lteak, the next time you are booted into the livesystem, could you get us the output of

lsblk -f -p

This way, we can see the actual partitions and their UUIDs and won’t have to guess anymore which one corresponds to which line in your fstab.

1 Like

I guess not certain. I based my comment on the structure of a default installation of fedora, which gave me this in fstab

UUID=bf958d55-772f-4694-946c-9e29501aeb89 / btrfs subvol=root,compress=zstd:1 0 0
UUID=b8eac66b-a895-46df-838a-9a05aaa9f968 /boot ext4 defaults 1 2
UUID=B0D7-A0F5 /boot/efi vfat umask=0077,shortname=winnt 0 2
UUID=bf958d55-772f-4694-946c-9e29501aeb89 /home btrfs subvol=home,compress=zstd:1 0 0

and this from lsblk

$ lsblk -f
NAME   FSTYPE FSVER LABEL  UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sr0                                                                            
zram0  swap   1     zram0  031947e1-4ca1-40c0-9848-c0d2d315d82d                [SWAP]
vda                                                                            
-vda1 vfat   FAT32        B0D7-A0F5                             579.5M     3% /boot/efi
-vda2 ext4   1.0          b8eac66b-a895-46df-838a-9a05aaa9f968    1.4G    22% /boot
-vda3 btrfs        fedora bf958d55-772f-4694-946c-9e29501aeb89    6.3G    61% /home
                                                                               /

With that config btrfs is clearly one volume with 2 subvolumes. I failed to note that he had different uuids and options.

Thanks for your patience and those further thoughts. I went to bed sick early last night and slept 15 hours. Here is the result (hand copied, since I have no way to get data off of my Linux machine at the moment)"
Lsblk -f -p
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
/dev/loop0 erofs c49c3ecb-832b-440f-89b5-a601286ebff0 0 100% /run/rootfsbase
/dev/sda
/dev/sda1
/dev/sda2 ntfs P5-E (not copied)
/dev/sda3 ntfs P5-F ditto
/dev/sda4 vfat fat32 P5-G ditto
/dev/sda5 vfat fat32 Disk_Sys ditto
/dev/sda6 swap 1
/dev/sdb
/dev/sdb1 exfat 1.0 Ventory 4E21-0000
/dev/sdb2 vfat FAT16 VTOYEFI E039-AD96
/dev/zram0 swap 1 zram0 f9bd099d-b39d-480a-867b-77fb63d49d24
/dev/nvme0
/dev/nvme0n1p1 vfat FAT32 D669-)B52
/dev/nvme0n1p2 ext4 1.0 c434373b-72fb-4622-bad7-657cf14cd228
/dev/nvme0n1p3 btrfs / 232a5005-d694-4e4e-b025-9e2e71c50e49
/dev/nvme0n1p4 btrfs Hiber 6978faa7-983f-4174-93c3-894a9c47716c
/dev/nvme0n1p5 btrfs /home 2e7bcaef-f294-4542-8df0-e86a508fd150

(Sorry, I had laid out in uniform colums, using spaces, but those got lost pasting it it.)

A further note. I had set up /home in a separate partition to avoid data loss, since I went through 4 fresh installs of fedora, while on my learning curve. (A carry over of a lesson hard-learned on Windows: don’t store anything anywhere on C: that you don’t want to lose in a reinstall.)