How to bootload openSUSE from another distribution's GRUB?

I tried to be smart and set up a triple boot system (using EFI) with Fedora (mbr/primary guid), Windows 10 and openSUSE, using only Fedora’s GRUB. So when installing openSUSE I didn’t specify any ESP i.e. /boot/efi and only created a partition for root. O:)

My question is: How should I go about creating the right initframs & GRUB entry to be able to boot on openSUSE from Fedora’s GRUB?

I’d like to avoid reinstalling any OS if possible…

Thanks in advance for you kind help,

Merryn

It would have been easier to just use the same ESP (use the expert partitioner during boot, and set that to mount at “/boot/efi”.

It’s not completely clear what you did.

If you are using secure-boot, you probably need to disable that. When booting with Fedora, with secure-boot the kernel would need to be signed by the fedora signing cert. So turning off secure-boot avoids that problem.

You can possibly add something like this to the Fedora grub.cfg (or whatever file you use to customize):


menuentry "OpenSUSE Leap 15.1"   {
        insmod btrfs
        search --fs-uuid --set=root 1234-5678-abcd-efgh
        linux /boot/vmlinuz root=/dev/disk/by-uuid/1234-5678-abcd-efgh
        initrd /boot/initrd
}

This is off the top of my head, and not tested.

Notes: The “insmod btrfs” assumes that you are using “btrfs” for the openSUSE root file system. If you are using a different file system, change as needed.

Use the actual UUID of the root file system, not the made-up string that I put there. You can get the UUID with the “blkid” command.

This does assume that there is a symlink for “vmlinuz” and for “initrd” (this is usually the case with openSUSE).

Installed openSUSE making sure /boot/efi was not touched at all by the installer, and didn’t install any bootloader. i only installed openSUSE at / mount point, on its own partition.

If you are using secure-boot, you probably need to disable that.

Yup did already!

You can possibly add something like this to the Fedora grub.cfg (or whatever file you use to customize):

menuentry “OpenSUSE Leap 15.1” {
insmod btrfs
search --fs-uuid --set=root 1234-5678-abcd-efgh
linux /boot/vmlinuz root=/dev/disk/by-uuid/1234-5678-abcd-efgh
initrd /boot/initrd
}

This is off the top of my head, and not tested.

Notes: The “insmod btrfs” assumes that you are using “btrfs” for the openSUSE root file system. If you are using a different file system, change as needed.

Use the actual UUID of the root file system, not the made-up string that I put there. You can get the UUID with the “blkid” command.

This does assume that there is a symlink for “vmlinuz” and for “initrd” (this is usually the case with openSUSE).

Excellent, will try this out. Just to be sure: these symlinks for vmlinuz and initrd are supposed to be generated by… what? Fedora? Because as I said above I didn’t touch /boot, so there is no way these symlinks were created by openSUSE’s installer… So how to generate them?

Thanks for helping me, really appreciate!

They should already be there. Just check to be sure.

When a kernel is installed in openSUSE, those symlinks are created for the most recently installed kernel.

You could, of course, use the complete kernel path instead of the symlink. But then you would have to update it for every kernel update on openSUSE. By using the symlink, you make sure that you are always using the most recently installed kernel.

This successfully added an entry point for openSUSE onto Fedora’s GRUB. However, when selecting the entry at boot time, got that: https://imgur.com/a/WhQCtUdhttps://imgur.com/a/WhQCtUdhttps://imgur.com/a/WhQCtUd](https://imgur.com/a/WhQCtUd)

which is hardly surprising because the only kernel image I have a symlink to is Fedora’s. How may I generate a kernel image for openSUSE, bearing in mind I have opted out from installing any bootloader when installing openSUSE?

If this is too tall an order, I think I will simply reinstall openSUSE. But then, my question becomes: What is the best practice for installing openSUSE making sure (i) openSUSE bootloader is not written into MBT and (ii) making sure that the other main Linux distro (i.e. Fedora) keeps responsibility for maintaining everything GRUB-related? I’ve read openSUSE’s docs but this scenario is not described at all.

I’m not an expert in grub internals. So I’m not sure what went wrong there.

As for reinstall? Can you provide the output from:

fdisk -l

or

parted -l

and indicate which partition is used by openSUSE. It will be easier to give advice with that knowledge.

Also, with “fedora” running, what is the output from

efibootmgr

or from

bootctl status

(I’m not sure whether Fedora has that last “bootctl” command).

This is to see if you are actually booting with UEFI.

Fedora booting from File = /EFI/FEDORA/SHIM64.EFI

Look, I really appreciate your help but I think I am taking a large detour (my fault: I’ve started with too strong an assumption when I said that I didn’t want any openSUSE bootloader). Instead the best scenario for me would be to simply reinstall openSUSE while making sure Fedora’s GRUB is always handled control first at boot. For that, installing openSUSE with recommanded settings (writing files at /boot/efi in my case) and then running grub2-mkconfig -o FEDORA-EFI-DIRECTORY and then making sure efibootmgr assigns the highest priority to Fedora’s EFI would do it, no?

If you reinstall, use the expert partitioner.

It will give you a choice – start with proposed partitioning or start with the original partition. Go with the original partitioning (what’s on the disk).

Set the opensuse root partition to be mounted at “/” and to be formatted.
Set any swap partition to be mounted as swap (but don’t format).

Set your EFI partition to be mounted at “/boot/efi”.

If your EFI partition is smaller than 250M, the installer will complain. Ignore the complaint and continue anyway.

Yes, this will probably put openSUSE first in boot order. But it should leave an entry for booting Fedora. You can change the boot order later. But running “grub2-mkconfig” is not the right way to change the boot order. You can boot to Fedora and reinstall grub2 there for that (probably “grub2-install” in fedora). Or you can use “efibootmgr -o” to set the boot order. And your BIOS might also have an option for that.

One of my machines has:

erlangen:~ # os-prober 
/dev/nvme0n1p1:Fedora 31 (Workstation Edition):Fedora:linux
/dev/nvme0n1p2:openSUSE Tumbleweed:openSUSE:linux
/dev/sda1:Manjaro Linux (18.1.3):ManjaroLinux:linux
/dev/sda2:openSUSE Leap 15.1:openSUSE:linux
/dev/sdb2:Arch Linux:Arch:linux
/dev/sdb3:SUSE Linux Enterprise Desktop 12 SP3:SLED:linux
/dev/sdb6:Ubuntu 19.10 (19.10):Ubuntu:linux
erlangen:~ # 

Every now and then a boot fails for some reason when configuring with os-prober. Therefore I switched it off and entirely rely on chain loading:

erlangen:~ # cat /etc/grub.d/40_custom 
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry 'SLED /dev/sdb3' {
    search --fs-uuid --no-floppy --set=root 6DEC-64F9
    chainloader /EFI/sled/grubx64.efi
}

menuentry 'Tumbleweed-ext4 /dev/nvme0n1p2' {
    search --fs-uuid --no-floppy --set=root 6DEC-64F9
    chainloader /EFI/tumbleweed-ext4/grubx64.efi
}

menuentry 'Arch Linux /dev/sdb2' {
    search --fs-uuid --no-floppy --set=root 4A24-B10D 
    chainloader /EFI/arch/grubx64.efi
}

menuentry 'Manjaro /dev/sda1' {
    search --fs-uuid --no-floppy --set=root 4A24-B10D 
    chainloader /EFI/manjaro/grubx64.efi
}

menuentry 'Leap 15.1 /dev/sda2' {
    search --fs-uuid --no-floppy --set=root 4A24-B10D 
    chainloader /EFI/leap-15.1/grubx64.efi
}

menuentry 'Fedora 31 /dev/nvme0n1p1' {
    search --fs-uuid --no-floppy --set=root 6DEC-64F9
    chainloader /EFI/fedora/grubx64.efi
}

menuentry 'Ubuntu 19.10 /dev/sdb6' {
    search --fs-uuid --no-floppy --set=root 6DEC-64F9
    chainloader /EFI/ubuntu/grubx64.efi
}
erlangen:~ # 

I do something similar here, except that I mostly use “configfile” rather than “chainloader”. Actually, “configfile” for systems that boot with “grub2”, and “chainloader” for systems that use some other means of booting.

However, to use this method you do need to install booting on each system. The OP had not done that.

Sure. But by default each system does exactly that and most of the time it works perfectly. efibootmgr allows to modify bootorder. Thus the machine will always boot your default system. You may boot another system by selecting the appropriate menu entry of the default system.

To summarize:

  • All systems have os-prober turned off
  • The primary system uses chain loading for booting secondary systems
  • The secondary systems don’t use chain loading
  • As all systems use only their native entry success is almost guaranteed.
  • As a bonus creating grub.cfg is really fast.

Thanks a lot, I did that and I finally ended up having the setting I wanted! Thanks for your help & patience!