grub restore only allows boot from 1 partition

I have 2 partitions of equal size on my laptop, about 26gb each, ext4 format. They are both used for a root partition, the idea being to have one as a backup in case one of the tumbleweed updates totally doesn’t work.

This is my partition setup:


**Device****     Start****       End****   Sectors****  Size****Type**
/dev/nvme0n1p1       2048    1026047    1024000   500M Microsoft basic data
/dev/nvme0n1p2    1026048   55711743   54685696  26.1G Linux filesystem
/dev/nvme0n1p3   55711744  110397439   54685696  26.1G Linux filesystem
/dev/nvme0n1p4  110397440 1943756799 1833359360 874.2G Linux filesystem
/dev/nvme0n1p5 1943756800 1953523711    9766912   4.7G Linux swap

When I run the procedure to restore/install grub, here is what I do. As root in a terminal:


> mkinitrd
> grub2-mkconfig -o /boot/grub2/grub.cfg  
Generating grub configuration file ...
Found theme: /boot/grub2/themes/openSUSE/theme.txt
Found linux image: /boot/vmlinuz-5.14.5-1-default
Found initrd image: /boot/initrd-5.14.5-1-default
Found linux image: /boot/vmlinuz-5.14.2-1-default
Found initrd image: /boot/initrd-5.14.2-1-default
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found openSUSE Tumbleweed on /dev/nvme0n1p3
Adding boot menu entry for UEFI Firmware Settings ...
done
> grub2-install /dev/nvme0
Installing for x86_64-efi platform.
Installation finished. No error reported.

Notice what the result is in the grub configuration file. I will leave out the advanced options on both partitions because they are the same with regard to what I found:


### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE Tumbleweed'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-ba22e191-xxxxxxxxxxxxxxxxxxx' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    search --no-floppy --fs-uuid --set=root ba22e191-xxxxxxxxxxxxxxxxxxx
    echo    'Loading Linux 5.14.5-1-default ...'
    linuxefi /boot/vmlinuz-5.14.5-1-default root=UUID=ba22e191-xxxxxxxxxxxxxxxxxxxx  splash=silent mitigations=auto quiet
    echo    'Loading initial ramdisk ...'
    initrdefi    /boot/initrd-5.14.5-1-default
}


### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'openSUSE Tumbleweed (on /dev/nvme0n1p3)' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-4efad914-xxxxxxxxxxxxxxxxxxxxxxx' {
    insmod part_gpt
    insmod ext2
    search --no-floppy --fs-uuid --set=root 4efad914-xxxxxxxxxxxxxxxxxxxxxxxx
    linuxefi /boot/vmlinuz-5.14.2-1-default root=UUID=ba22e191-xxxxxxxxxxxxxxxxxxx splash=silent mitigations=auto quiet
    initrdefi /boot/initrd-5.14.2-1-default
}

See how on the 2nd menu item in grub for my 2nd root partition, the menuentry line points to the right UUID for that partition, and the search line also points to the right UUID for that partition. However, the actual boot line that begins with linuxefi points back to the other root partition, the same as in the first menu entry in grub.

Am I doing something wrong in how I install grub? Or is this a bug in setting up grub?

I know I am not supposed to manually adjust the grub.cfg file, but what I found was that if I selected the 2nd root partition in grub, it would still mount and boot into the 1st root partition because of the wrong UUID specified on the linuxefi line. So I manually changed the UUID to the correct one on this line, and was able to boot into the 2nd root partition. But I don’t want to have to do this every time.

Hi
That’s because it’s using the same efi entry, you would need a separate efi directory called opensusebu or similar.

If your worried about a snapshot not working (not had that issue here) then look at using tumbleweed-cli to rollback to the previous snapshot.

User nrickert is up to speed running separate directories, hopefully he will reply :wink:

Looking at it now.

How did you install grub? You told us how you updated grub. Perhaps that is all you meant.

Yes, something is wrong, but I’m not sure what.

Your fix – manually editing “grub.cfg” is fine as a temporary workaround.

Is there anything in “/etc/default/grub” that might put the wrong “root=” information on that line?

For example, checking here I see:


# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
# GRUB_DISABLE_LINUX_UUID=true

If I were to uncomment that line, and instead add a “root=UUID=xxx” parameter to the line for


GRUB_CMDLINE_LINUX_DEFAULT=

then I think that would cause the problem that you are seeing.

Any time you have two of the “same” distro on the same PC it’s best to identify each uniquely for UEFI purposes. malcolmlewis touched this briefly. The simplest method for that is /etc/default/grub, the line “GRUB_DISTRIBUTOR=”. In all openSUSE releases this value ships null, with the consequence the resulting value used on disk is /boot/efi/EFI/opensuse. Change it to e.g. opensusetw for one in /etc/default/grub, and from the next grub.cfg generation on (via YaST; otherwise more might be necessary), each installation should appear distinct from the other for bootloader and UEFI purposes, via separate directories on the ESP. It’s the same issue for people using both Leap and TW.

Well, yes, if he had been selecting which to boot at the BIOS UEFI boot menu, he would not have run into this problem. However, what he is doing should work, and works fine for many people. He has a problem in “grub.cfg” which is not related to UEFI.

What exactly “backup” means? Do you copy content of one filesystem into another?

grub2-install /dev/nvme0

Device /dev/nvme0 does not exist. This line does not result in error only because grub2-install ignores this parameter on EFI.

Am I doing something wrong in how I install grub?

You never described how you installed grub, so we have no way to decide whether you did something wrong.

Show full protocol of

lsblk -f
cat /etc/fstab
START=$(date +%s)
grub2-mkconfig
journalctl --since=@$START

on the system where you observed wrong results; then boot into another system and show output of

lsblk -f
cat /etc/fstab
cat /boot/grub2/grub.cfg

Ok, I looked over both of these suggestions and feel kind of at a loss. Here is my grub.cfg file:

> cat /etc/default/grub
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
# /boot/grub2/grub.cfg.

# Uncomment to set your own custom distributor. If you leave it unset or empty, the default
# policy is to determine the value from /etc/os-release
GRUB_DISTRIBUTOR=
GRUB_DEFAULT=saved
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=8
GRUB_CMDLINE_LINUX_DEFAULT="splash=silent mitigations=auto quiet"
GRUB_CMDLINE_LINUX=""

# Uncomment to automatically save last booted menu entry in GRUB2 environment

# variable `saved_entry'
# GRUB_SAVEDEFAULT="true"
#Uncomment to enable BadRAM filtering, modify to suit your needs

# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
# GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
#Uncomment to disable graphical terminal (grub-pc only)

GRUB_TERMINAL="gfxterm"
# The resolution used on graphical terminal
#note that you can use only modes which your graphic card supports via VBE

# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE="auto"
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
# GRUB_DISABLE_LINUX_UUID=true
#Uncomment to disable generation of recovery mode menu entries

# GRUB_DISABLE_RECOVERY="true"
#Uncomment to get a beep at grub start

# GRUB_INIT_TUNE="480 440 1"
GRUB_BACKGROUND=
GRUB_THEME=/boot/grub2/themes/openSUSE/theme.txt
SUSE_BTRFS_SNAPSHOT_BOOTING="true"
GRUB_USE_LINUXEFI="true"
GRUB_DISABLE_OS_PROBER="false"
GRUB_ENABLE_CRYPTODISK="n"
GRUB_CMDLINE_XEN_DEFAULT="vga=gfx-1024x768x16"


So from this I cannot see the error. This default grub file is from the original tumbleweed installation and I have never changed anything in it.

Would you suggest I uncomment the line GRUB_DISABLE_LINUX_UUID=true ? Or do something else to that line?

No. Leave those as they are. And continue manually editing “grub.cfg” (as a workaround) for now.

I suggest that you report a bug for this.

openSUSE:Submitting bug reports

Ok, thanks :slight_smile:

https://bugzilla.opensuse.org/show_bug.cgi?id=1190874

Thanks. That will get it to the attention of the grub2 software maintainers.