GRUB2 os-prober does not generate correct entries for booting Manjaro as 2nd operating system

My laptop is UEFI-booted from a GPT-partitioned internal SSD. I have two Linux systems on it. openSUSE Tumbleweed is my main production system, while another Linux is available as an emergency operating system in case something happens to Tumbleweed. This concept has helped me a lot a few times. For a long time, I had Linux Mint Cinnamon as the 2nd OS. I decided now to try something else in order to get away from the trodden Ubuntu path of outdated software versions and the need for PPAs. After extensive research into Linux distros, I am now trying Manjaro (rolling release concept, up-to-date software, and - putting it simplistically - Arch without the Arch pains).

Tumbleweed shall remain my main production system. Among other things, this means Tumbleweed is responsible for maintaining the GRUB2 bootloader and its configuration as well as boot menu by running

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

every time anything OS-related changes in either of my two systems.

Unfortunately, Tumbleweed currently does not generate correct GRUB2 menu entries for Manjaro via the os-prober.

When I use the Manjaro entries as written from Tumbleweed’s grub2-mkconfig script to /boot/grub2/grub.cfg, booting into Manjaro simply results in Kernel Panic (failure message s.th. like “can’t load VFS file system”; I don’t remember precisely, could reproduce it, but it’s not necessary at this point in time since I know what’s wrong - cf. next paragraph).

By simply comparing the grub.cfg file as written from within Tumbleweed to the one that was written by Manjaro (“for itself”), it is obvious what is going wrong:

/boot/grub/grub.cfg by Manjaro for itself:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Manjaro Linux' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7b00f0cc-307f-40a2-bff2-a1f767ee15f5' {
    savedefault
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt2'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  7b00f0cc-307f-40a2-bff2-a1f767ee15f5
    else
      search --no-floppy --fs-uuid --set=root 7b00f0cc-307f-40a2-bff2-a1f767ee15f5
    fi
    echo    'Loading Linux 4.14.16-1-MANJARO x64 ...'
    linux    /boot/vmlinuz-4.14-x86_64 root=UUID=7b00f0cc-307f-40a2-bff2-a1f767ee15f5 rw  quiet resume=UUID=d0e52c5d-112b-47dc-aa2c-7e1e31e38323
    echo    'Loading initial ramdisk ...'
    initrd    /boot/intel-ucode.img /boot/initramfs-4.14-x86_64.img
}

/boot/grub2/grub.cfg by Tumbleweed’s os-prober for Manjaro:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Manjaro Linux (17.1.4) (auf /dev/sda2)' --class manjarolinux --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-7b00f0cc-307f-40a2-bff2-a1f767ee15f5' {
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt2'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  7b00f0cc-307f-40a2-bff2-a1f767ee15f5
    else
      search --no-floppy --fs-uuid --set=root 7b00f0cc-307f-40a2-bff2-a1f767ee15f5
    fi
    linuxefi /boot/vmlinuz-4.14-x86_64 root=UUID=7b00f0cc-307f-40a2-bff2-a1f767ee15f5 rw quiet resume=UUID=d0e52c5d-112b-47dc-aa2c-7e1e31e38323
    initrdefi /boot/intel-ucode.img
}

The crucial erroneous statement is the last initrd line. Tumbleweed’s os-prober is missing the /boot/initramfs-4.14-x86_64.img after /boot/intel-ucode.img. Just adding the missing piece in the various places both in the main and advanced GRUB2 menu sections results in everything working fine.

Remark: I am not sure about the differences between linux versus linuxefi as well as initrd versus initrdefi. My PC doesn’t have Secure Boot in its UEFI. Whatever the reason was for Manjaro to use linux and initrd only instead of linuxefi and initrdefi (Tumbleweed), I checked that both do work.

Remark 2: My laptop is an HP EliteBook 8560w dating back to 2011. At that time, HP merely had a half-baked UEFI implementation. This requires a /boot/efi/EFI/BOOT/bootx64.efi as the bootloader code (original Microsoft Win 8 style), which is achieved by simply copying and renaming the grubx64.efi files created by the various operating system as /boot/efi/EFI/os-name/grubx64.efi to /boot/efi/EFI/BOOT/bootx64.efi as desired.

My question to the community is: Since it is both undesirable and “forbidden” to edit the /boot/grub.cfg file manually, I would like to get help on how I can get Tumbleweed’s grub2-mkconfig script and the templates from /etc/grub.d as well as the settings from /etc/default/grub to generate correct os-prober entries for Manjaro.

Thanks a lot in advance!

Firstly, on the difference between “linux” and “linuxefi”.

If you are not using secure-boot, then it usually won’t matter. Basically, “linuxefi” loads the kernel at its EFI stub (whatever that means), and is needed for checking signatures on signed kernels. I’m assuming that you have secure-boot disabled.

Secondly: here’s what I do. I add some entries to “/etc/grub.d/40_custom” to boot other linux versions.

Here’s an example:


### Entry to boot openSUSE 42.2 on sdb2
menuentry "configfile for openSUSE 42.2 on /dev/sdb2"  {
        set bootdir='hd2,gpt2'
        search --fs-uuid --set=bootdir ce14101d-f8d6-483a-948b-ee2b631c1bbc
        configfile (${bootdir})/grub2/grub.cfg
}

The “set bootdir=” part doesn’t really do anything. The search for UUID finds the boot partition for the secondary linux. And it then uses the “configfile” command to boot it.

The huge benefit of this, is that if I do a kernel update on the secondary linux, it still works. I don’t have to run “grub2-mkconfig” on my primary linux, because it is directly using the boot configuration of the secondary linux. I actually turn os-prober off (in “/etc/default/grub”) unless there’s a Windows partition that I want it to pick up.

Thanks, sounds like a good concept. I will turn to it tomorrow - eager to see it!

@nrickert: Thanks a lot again for this concept. Unfortunately, it seems I am unable yet to make it work. Moreover, I don’t have my fat Linux book (Kofler) with me right now.

First, the os-prober is disabled in both the primary and the secondary Linux by having a line like

GRUB_DISABLE_OS_PROBER="true"

in both their /etc/default/grub files. Probably this is the default, so this line actually might be unneccessary.

Second, both the /boot/grub2/grub.cfg for Tumbleweed and the /boot/grub/grub.cfg for Manjaro, respectively, now have the full set of sections except for the 30_os-prober’s being blank. The sections are:
00_header (long standard stuff)
00_tuned (set 2 tuned_X to “”)
10_linux (their respective complete menu entries)
20_linux_xen, 30_os-prober (empty)
40_custom (cf. below)
41_custom (cf. below)
80_suse_btrfs_snapshot (Tumbleweed, empty)
90_persistent (empty)
95_textmode (standard stuff)

On the primary OS, Tumbleweed, my 40_custom now reads

#!/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.

### Entry to boot Manjaro Linux on sda2
menuentry "Boot Entries for Manjaro Linux on /dev/sda2" {
    set bootdir='hd0,gpt2'
    search --fs-uuid --set=bootdir 7b00f0cc-307f-40a2-bff2-a1f767ee15f5
    configfile (${bootdir})/grub/grub.cfg
}


It is meant to boot into the secondary OS, Manjaro. Manjaro’s root partition is /dev/sda2, and thus I am assuming this 40_custom should have

  • ‘hd0,gpt2’,
  • the UUID of /dev/sda2, i.e. 7b00f0cc-307f-40a2-bff2-a1f767ee15f5,
  • and ($bootdir)/grub/grub.cfg, since Manjaro’s grub.cfg sits in Manjaro’s /boot/grub directory (not in a /boot/grub2).

nrickert, please confirm or correct my assumptions. In fact, I am deviating from your example given yesterday, where you say to have the secondary OS on /dev/sdb2, but have a ‘hd2,gpt2’ statement.

On the secondary OS, Manjaro, its /boot/grub/grub.cfg has all the things originally written by Manjaro, i.e. all sections, ‘hd0,gpt2’ as well as the UUID 7b00f0cc-307f-40a2-bff2-a1f767ee15f5 of /dev/sda2.

On my part, I don’t understand what the 41_custom as per the original Tumbleweed and Manjaro templates do.

Now, the issue is: Hitting the new GRUB2 menu entry “Boot Entries for Manjaro Linux on /dev/sda2” just doesn’t do anything except for a flicker of the screen (maybe an error message is flashed), whereafter it jumps right back and highlights the standard default menu entry called “Tumbleweed”.

nrickert, it would be great if you please could check this and let me know what I am missing. (Remark: I also did try to be in line with your example by reluctantly putting an ‘hd1,gpt2’ into my 40_custom, but that didn’t work either.)

Thanks a lot in advance!

Indeed, neat concept, but initially had same negative result as you have with the example code (modified). Changed same parts as in your example, except os-prober is NOT disabled here, for Win 7 still present. Changes were: ‘hd0,msdos10’; different UUID; and Manjaro’s /grub/grub.cfg. However the latter change was incomplete and needs to be:

configfile (${bootdir})/boot/grub/grub.cfg

Now it works! The clue for me was was in your post at:

and ($bootdir)/grub/grub.cfg, since Manjaro’s grub.cfg sits in Manjaro’s /boot/grub directory (not in a /boot/grub2).

and

On the secondary OS, Manjaro, its/boot/grub/grub.cfg has all the things originally written by Manjaro…

Thanks very much for starting this thread. Before this solution, and to overcome Tumbleweed’s failure to boot Manjaro, I used Manjaro as primary OS by switching Boot flag (usiing Gparted) to its partition instead of Tumbleweed’s. Manjaro’s grub worked perfectly for booting other OS’s, but with overheads of running Manjaro’s “update-grub” for Tumbleweed’s too frequent kernel upgrades. :wink:

Thanks a lot for stepping in, consused, and providing the solution by correcting /grub/grub.cfg to read /boot/grub/grub.cfg. In fact, I have just been doing that very same change and saw it working.

And, BTW, consused, since you are using Manjaro as I am: I found that I still need to work on making Tumbleweed the initial default GRUB menu entry again, since Manjaro seems to have captured that position. Work in progress, maybe you know right away how to do that.

Thanks again. Always happy to start a thread that turns out to be sharing know-how in the community.

Head not totally around this yet… suspecting answer probably lies in “/etc/default/grub” file.

Manjaro’s GRUB appears to remember “last booted menu entry”. I think Tumbleweed usually defaults to the first (top) menu entry (here that is also the Tumbleweed entry).

Booting with primary Tumbleweed’s GRUB, now manually selecting custom “configfile” as last menu entry, boots to secondary Manjaro. Restarting from Manjaro returns to Tumbleweed’s GRUB menu with the custom menu entry now preselected. That “last booted menu entry” appears to be saved somewhere.

On Leap 42.3 right now, assuming same default as Tumbleweed, looking in “/etc/default/grub”, I see:

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

# variable `saved_entry'
# GRUB_SAVEDEFAULT="true"

I’m guessing therefore Manjaro activates similar code, and you might deactivate it to achieve your goal (if that is what you meant to achieve?), also remembering to run “update-grub” after changes.

The default (for openSUSE) is to have that line there, but commented out. So removing the “#” at the beginning, so it is not a comment, stops os-prober from being automatically run.

On the primary OS, Tumbleweed, my 40_custom now reads

#!/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.

Entry to boot Manjaro Linux on sda2

menuentry “Boot Entries for Manjaro Linux on /dev/sda2” {
set bootdir=‘hd0,gpt2’
search --fs-uuid --set=bootdir 7b00f0cc-307f-40a2-bff2-a1f767ee15f5
configfile (${bootdir})/grub/grub.cfg
}

From here, that looks okay.

Note, however: If manjaro has a separate “/boot” partition, then you need the UUID of “/boot” there.

If it does not have a separate “/boot”, then you would need: (${bootdir})/boot/grub/grub.cfg

I’ve run into that from time to time. As far as I know, “${bootdir}” is just a name that I picked. It turns out that some names such as $prefix and $root have special significance to grub. So I avoided those.

It is meant to boot into the secondary OS, Manjaro. Manjaro’s root partition is /dev/sda2, and thus I am assuming this 40_custom should have

  • ‘hd0,gpt2’,
  • the UUID of /dev/sda2, i.e. 7b00f0cc-307f-40a2-bff2-a1f767ee15f5,
  • and ($bootdir)/grub/grub.cfg, since Manjaro’s grub.cfg sits in Manjaro’s /boot/grub directory (not in a /boot/grub2).

You will need
($bootdir)/boot/grub/grub.cfg
there. Here $bootdir is the directory you found with the UUID. Since that is the root directory, you need that “/boot” in the path.

nrickert, please confirm or correct my assumptions. In fact, I am deviating from your example given yesterday, where you say to have the secondary OS on /dev/sdb2, but have a ‘hd2,gpt2’ statement.

The “gpt2” is because this is a GPT partitioned disk. Otherwise, try “msdos”. But, honestly, it doesn’t do anything. If you get the UUID wrong, it will be used. But the partition number is unreliable.

On my system, that “hd2,gpt2” refers to a partition on my second hard drive. But if there is a USB device plugged in, then it needs to be “hd3” rather than “hd2”. And it is “hd2” rather than “hd1” because it is seeing the DVD as “hd1”. Even if I move the SATA connectors around, the DVD still is “hd1”. It has to do with how the BIOS numbers things. So it is not reliable, and the UUID is what really does the work. If you get the UUID right, then the disk number doesn’t matter.

On my part, I don’t understand what the 41_custom as per the original Tumbleweed and Manjaro templates do.

I have never used 41_custom. It looks to me as if I am not supposed change it. It looks in “/boot/grub2” to see if there is a file “custom.cfg”, and imports that into the configuration.

I think what you have is good, except for that missing “/boot” part of the path.

Thanks, nrickert, for your comprehensive explanations. All set now, works fine so far. I am just left with figuring out how to pick one GRUB menu (the Tumbleweed primary one) entry as default and make it stick. Manjaro is doing s.th. of its own, I want to get rid of that default.

The one that “sticks” is the one that the BIOS uses.

For UEFI, this depends on the NVRAM entries, and might keep changing (depending on firmware). For legacy booting, it probably depends on whether grub is installed in the MBR or in a partition.

By default, on mine, Manjaro has enabled this line in its /etc/default/grub:

# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true

and also has in its first line:

GRUB_DEFAULT=saved

To preserve the Tumbleweed default GRUB menu entry, I would probably need to “comment out” GRUB_SAVEDEFAULT on Manjaro and change its first line to:

GRUB_DEFAULT=' '

although not yet sure what that last value should be.

On second thoughts re Manjaro’s /etc/default/grub, I would leave GRUB_DEFAULT as it is:

GRUB_DEFAULT=saved

That is the same setting as in Tumbleweed’s /etc/default/grub, where in mine a GRUB_SAVEDEFAULT line is totally absent i.e. not enabled. How silly of me to assume in earlier post it was similar to statements in Leap 42.3 :.

Thanks to you both.

With respect to making the last booted menu entry the default for the next boot, my current solution is as follows: I now have the two lines

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT="true"

in the /etc/default/grub files on both the primary Linux (Tumbleweed) and the secondary one (Manjaro). At least as much as I tested it up to now, it works like I want it. Both GRUB menues (the Tumbleweed one with entries “Tumbleweed” / “Advanced options for T…” / “Menu entries for Manjaro”, and the Manjaro one with entries “Manjaro” / “Advanced options for M…”) seem to remember separately what I asked them to do the last time.

Otherwise, if one wouldn’t like to remember which menu entry was executed the last time, the /etc/default/grub file would have to have

GRUB_DEFAULT=0
# GRUB_SAVEDEFAULT="true"
or - yet a guess on my side - GRUB_SAVEDEFAULT="false"

asking GRUB to preselect the first menu entry at boot-up.

Guess I could mark this thread as “SOLVED” with respect to the original question “how can Tumbleweed’s GRUB2 properly boot a Manjaro Linux?”. Well, if I knew how to put a “SOLVED” into the thread’s title…

Yes, that would be my first combo to test, when I get to it. Although with four OS’s in multiboot, I might prefer how it was before Manjaro introduced me to that option. Once a secondary OS is selected on the primary, it usually remains my target especially if/when reaching the timeout on the second!

Otherwise, if one wouldn’t like to remember which menu entry was executed the last time, the /etc/default/grub file would have to have

GRUB_DEFAULT=0
# GRUB_SAVEDEFAULT="true"

asking GRUB to preselect the first menu entry at boot-up.

What occurred with “GRUB_DEFAULT=saved”, the default on Tumbleweed, still present here? Did you find any reference doc to possible values for that setting?

Marking threads solved is not required, and with this kind of topic others may add alternatives much later on which is to be encouraged. :wink:

Well, a couple of hours later I‘m not sure whether I‘ll stay happy with my solution.

For references, I use the „Linux Handbuch“ by Kofler (German) and the official GRUB2 Manual (Google „GRUB2 manual pdf“). Hope that helps.

Thank you for the references. I had only browsed the “Info” pages for grub2, ok for intro/concept, not enough detail.

Thinking I could end up with Tumbleweed-primary GRUB saving previous menu entry; Manjaro-secondary GRUB keeping itself as default menu entry (as with other secondary OS’s now).

On the first custom “configfile” run I almost missed the fact that Manjaro-secondary menu had appeared because it displayed in Tumbleweed’s background colour and font with only a slightly different order of secondary OS’s. :smiley:

Yes, os-prober does not handle multi-part initrds well. Unfortunately fixing it is not entirely trivial and needs coordinated change in grub and os-prober (and handling of spaces in shell is not fun either). May be I should revisit it. In the meantime as was suggested create manual entry (better simply chainload Manjaro grub so you get actual kernel selection).