Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Two distributions on two hard disks (no ssd), one grub
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Thu Apr 10, 2025 9:08 pm    Post subject: Two distributions on two hard disks (no ssd), one grub Reply with quote

Are necessary two grub installations, one for each linux distribution?

Scenario
I'm trying to install gentoo on /dev/sda2.
There is an opensuse distribution on /dev/sdb4.
Opensuse installed grub (grub2) on /dev/sdb1.
Opensuse detects gentoo via os-prober on /dev/sda2.
There is no separate partition for /boot, neither in gentoo nor in opensuse.
After reboot, both options appear: if I choose opensuse, it run nicely. otherwise it freezes.

For gentoo intallation:
USB gentoo live, chroot gentoo, downloaded kernel gentoo-sources, make && make intall && make modules_install: all three ok.
/etc/fstab first try: UUID=14ea62b0-b71d-48eb-857a-2f395ce2a93f / ext4 defaults 0 1
/etc/fstab second try: /dev/sda2 / ext4 defaults 0 1
Installed dracut and run to get iniramfs
No grub was installed onto /dev/sda.
Reboot, choose opensuse, update grub running grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot, choose gentoo, it freezes just after bios invokes dracut.

Deep breath! Forget dracut.
USB gentoo live, chroot gentoo, install genkernel, run genkernel --install iniramfs (root=/dev/sda2 on config file)
Reboot, choose opensuse, update grub running grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot, choose gentoo, it freezes with error message:
"Determining root device trying /dev/sda2"
"Block device /dev/sda2 is not a valid root device"
But both from live usb and from opensuse I can mount, read, edit, write and excute files in /dev/sda2!

Now I am stuck and need help.
I doubt the problem is the absence of grub on sda.
Suggestions?
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1852
Location: South America

PostPosted: Thu Apr 10, 2025 10:02 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

otaviolb wrote:
Are necessary two grub installations, one for each linux distribution?

No. One single instance of GRUB per machine is enough (and is in fact the minimal setup), but it can be hard to get the necessary grub.cfg right, and to keep the non-Gentoo distribution from messing it up later, so maybe high maintenance for some people's taste.

GRUB itself —i. e. the actual bootloader bits— is quite smart, but grub-mkconfig, the helper tool, has its limits.

otaviolb wrote:
Reboot, choose opensuse, update grub running grub2-mkconfig -o /boot/grub2/grub.cfg
[...]
Suggestions?

Could you post the generated configuration file?
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2234

PostPosted: Fri Apr 11, 2025 9:37 am    Post subject: Reply with quote

IIUC grub-mkconfig should be able to handle this case if you have installed sys-boot/os-prober.
Otherwise you can run mkconfig on each separate OS, and manually combine the grub.cfg entries, though that may be a hassle if you generate unique (i.e. versioned) kernel filenames.
Using versioned kernel names makes life unnecessarily complicated, as you need to change grub.cfg for each new version. Using "xmlinuz" symbolic links means that grub.cfg can remain the same, potentially forever...
_________________
Greybeard
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Fri Apr 11, 2025 10:08 am    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

Quote:
Could you post the generated configuration file?


Are you sure? Its over 300 lines!
If you confirm, I post i all.

Here are the lines greped with the keyword "gentoo":

Code:
menuentry 'Gentoo Linux (on /dev/sda2)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
        initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
submenu 'Advanced options for Gentoo Linux (on /dev/sda2)' $menuentry_id_option 'osprober-gnulinux-advanced-6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
        menuentry 'Gentoo Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
                initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
        menuentry 'Gentoo Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
        menuentry 'Gentoo Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
                initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
        menuentry 'Gentoo Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Fri Apr 11, 2025 12:01 pm    Post subject: Reply with quote

Goverp wrote:
...Otherwise you can run mkconfig on each separate OS, and manually combine the grub.cfg entries, ...

In this case I would have to install grub also in gentoo. I'm trying to avoid this.

Goverp wrote:
... Using versioned kernel names makes life unnecessarily complicated, as you need to change grub.cfg for each new version. Using "xmlinuz" symbolic links means that grub.cfg can remain the same, potentially forever...

Fortunately I am not using versioned filenames. /boot looks like this:

Code:
localhost:~ # ls -l  /mnt/gentoo/boot/
total 32952
-rw-r--r-- 1 root root  8111471 Apr  8 10:39 System.map
-rw-r--r-- 1 root root   166904 Mar 25 19:18 config-6.12.16-gentoo-dist
-rw-r--r-- 1 root root 12298556 Apr 10 10:03 initramfs-6.12.16-gentoo-150600.23.42-default.img
lrwxrwxrwx 1 root root       49 Apr  8 15:40 initramfs.img -> initramfs-6.12.16-gentoo-150600.23.42-default.img
-rw-r--r-- 1 root root 13156864 Apr  8 10:39 vmlinuz
localhost:~ #
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 765

PostPosted: Fri Apr 11, 2025 12:16 pm    Post subject: Reply with quote

Goverp wrote:
IIUC grub-mkconfig should be able to handle this case if you have installed sys-boot/os-prober.
Indeed, as long as it's not disabled in /etc/default/grub. Worst case scenario is having to use chainloading, a chainload entry isn't going to change, so you can add it "permanently" using /etc/grub.d/, but os-prober should do the job.

Quote:
In this case I would have to install grub also in gentoo. I'm trying to avoid this.
There is a difference between emerging grub2, and running grub-install afterwards; depending on dependencies, you could probably get away with running /mnt/suse/usr/bin/grub-mkconfig. The truly elegant solution would be to not use os-prober, and copy the /etc/grub.d/10-linux from gentoo as /etc/grub.d/11-gentoo, then alter it so it mounts your relevant gentoo drives, and uses those as search paths: At a cursory glance, updating $GRUB_DEVICE{_PARTUUID} might be enough, though pointing these may be needed to reach gentoo's /usr/share/grub/grub-mkconfig_lib (which you may also have to tinker with)
/etc/grub.d/11-gentoo:
prefix="/mnt/gentoo/usr"
exec_prefix="/mnt/gentoo/usr"
datarootdir="/mnt/gentoo/usr/share"


Last edited by Ralphred on Fri Apr 11, 2025 12:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5611
Location: Bavaria

PostPosted: Fri Apr 11, 2025 12:27 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

otaviolb wrote:
Quote:
Could you post the generated configuration file?


Are you sure? Its over 300 lines!

Please use wgetpaste for this: https://wiki.gentoo.org/wiki/Wgetpaste
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1852
Location: South America

PostPosted: Fri Apr 11, 2025 12:54 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

otaviolb wrote:
Are you sure? Its over 300 lines!
If you confirm, I post i all.

Yes, please. A correct grub.cfg is essential for this setup to work, and we need to see if openSUSE's grub2-mkconfig and os-prober were able to figure it out . Use wgetpaste to put it in a pastbin site, as pietinger said, and post the returned link.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Fri Apr 11, 2025 6:17 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

GDH-gentoo wrote:
otaviolb wrote:
Are you sure? Its over 300 lines!
If you confirm, I post i all.

Yes, please. A correct grub.cfg is essential for this setup to work, and we need to see if openSUSE's grub2-mkconfig and os-prober were able to figure it out . Use wgetpaste to put it in a pastbin site, as pietinger said, and post the returned link.


I never did this. Please, take a look at
https://bpa.st/FA4A
Back to top
View user's profile Send private message
flysideways
Guru
Guru


Joined: 29 Jan 2005
Posts: 502

PostPosted: Sat Apr 12, 2025 5:20 pm    Post subject: Reply with quote

A workflow that keeps things simple, is to fully install each distro without any mods on its respective drive, as each distro recommends. Call them A and B.

Then, decide which one you are going to set as the default boot device in your bios (A). On that one (A), enable osprober. That install (A) will boot itself, or allow you to select the other (B) from the menu.

With this setup it is also easy to use the motherboard bios bootselect menu to boot (B) and chroot into (A) if you have made it (A) in need of repair. 8)
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 3013
Location: Edge of marsh USA

PostPosted: Sat Apr 12, 2025 9:40 pm    Post subject: Reply with quote

Several times in my recent experience, OS-Prober has a fairly high likelihood of writing incorrect information about the discovered OS. It may serve you well to micro-analyze grub.cfg looking for errors in partition identifiers like UUID, PARTUUID, set root, root=, and so on.

Backup the generated grub.cfg before making any hand edits.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1852
Location: South America

PostPosted: Sat Apr 12, 2025 9:55 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

otaviolb wrote:
I never did this.

It worked.

otaviolb wrote:
Please, take a look at
https://bpa.st/FA4A

Is the filesystem UUID of /dev/sda2 really 6b778e67-7154-4fbc-9c39-d149fe4ba9b8? You can verify this in openSUSE with lsblk -o NAME,UUID.

If yes, could you change these two lines:
Code:
   linux /boot/vmlinuz root=/dev/sda2
   initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img

in menu entry "osprober-gnulinux-simple-6b778e67-7154-4fbc-9c39-d149fe4ba9b8" to:

Code:
      load_video
      set gfxpayload=keep
      echo   'Loading Gentoo kernel ...'
      linux /boot/vmlinuz  root=UUID=6b778e67-7154-4fbc-9c39-d149fe4ba9b8
      echo   'Loading initial ramdisk ...'
      initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
?

Before booting, make sure that the output of:
Code:
$ grub2-scriptcheck /boot/grub2/grub.cfg && echo OK || echo Error

is "OK". Do back up the file before editing as figueroa says.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Mon Apr 14, 2025 11:43 am    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

GDH-gentoo wrote:

Is the filesystem UUID of /dev/sda2 really 6b778e67-7154-4fbc-9c39-d149fe4ba9b8? You can verify this in openSUSE with lsblk -o NAME,UUID.

Yes, it is.

GDH-gentoo wrote:

If yes, could you change these two lines:
Code:
   linux /boot/vmlinuz root=/dev/sda2
   initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img

in menu entry "osprober-gnulinux-simple-6b778e67-7154-4fbc-9c39-d149fe4ba9b8" to:

Code:
      load_video
      set gfxpayload=keep
      echo   'Loading Gentoo kernel ...'
      linux /boot/vmlinuz  root=UUID=6b778e67-7154-4fbc-9c39-d149fe4ba9b8
      echo   'Loading initial ramdisk ...'
      initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
?

Done.

GDH-gentoo wrote:

Before booting, make sure that the output of:
Code:
$ grub2-scriptcheck /boot/grub2/grub.cfg && echo OK || echo Error


Sorry, suse does not have this scriptcheck.

GDH-gentoo wrote:

Do back up the file before editing as figueroa says.

Done. I made a copy and a patch:
Code:
localhost:~ # cat /boot/grub2/grub.patch
--- grub.cfg    2025-04-14 07:28:54.072290802 -0300
+++ grub_cfg-suse-original      2025-04-10 10:10:10.229801288 -0300
@@ -214,16 +214,8 @@
        else
          search --no-floppy --fs-uuid --set=root 6b778e67-7154-4fbc-9c39-d149fe4ba9b8
        fi
-#      linux /boot/vmlinuz root=/dev/sda2
-#      initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
-       load_video
-       set gfxpayload=keep
-       echo   'Loading Gentoo kernel ...'
-       linux /boot/vmlinuz  root=UUID=6b778e67-7154-4fbc-9c39-d149fe4ba9b8
-       echo   'Loading initial ramdisk ...'
+       linux /boot/vmlinuz root=/dev/sda2
        initrd /boot/initramfs-6.12.16-gentoo-150600.23.42-default.img
-# Editado em 14 de abril de 2025
-# https://forums.gentoo.org/viewtopic-p-8859171-highlight-.html#8859171
 }
 submenu 'Advanced options for Gentoo Linux (on /dev/sda2)' $menuentry_id_option 'osprober-gnulinux-advanced-6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {
        menuentry 'Gentoo Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--6b778e67-7154-4fbc-9c39-d149fe4ba9b8' {


After reboot I get:
Code:

>> Genkernel 4.13.16 ...[[i]today's date[/i]] ... Linux kernel 6.12.16-gentoo-150600.23.42-default
>> Activating udev
>> Determining root device (trying /dev/sda2)
!! Block device /dev/sda2 is not a valid root device
!! Could not find the root block device in /dev/sda2
[[i]some choices are given[/i]]
root clock device (/dev/sda2) ::

The last line is greyed out and keyboard stops to be responsive.
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1852
Location: South America

PostPosted: Mon Apr 14, 2025 12:42 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

otaviolb wrote:
After reboot I get:
Code:
>> Genkernel 4.13.16 ...[[i]today's date[/i]] ... Linux kernel 6.12.16-gentoo-150600.23.42-default
>> Activating udev
>> Determining root device (trying /dev/sda2)
!! Block device /dev/sda2 is not a valid root device
!! Could not find the root block device in /dev/sda2
[[i]some choices are given[/i]]
root clock device (/dev/sda2) ::

The last line is greyed out and keyboard stops to be responsive.

This means that GRUB worked and loaded Gentoo's kernel and initramfs —which looks like it is the one you made with Genkernel—, and the kernel did boot, but the initramfs has encountered a problem. Was this different to the previous attempts, or is this what was actually happening the whole time? Did you see the "Loading Gentoo kernel ..." message that the patched grub.cfg should have printed?

I don't use Genkernel, so unfortunately I can't give advice on how to fix this other than saying that the udev instance cointained in the initramfs seems to be having some kind of trouble.
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Mon Apr 14, 2025 1:32 pm    Post subject: Re: Two distributions on two hard disks (no ssd), one grub Reply with quote

GDH-gentoo wrote:

This means that GRUB worked and loaded Gentoo's kernel and initramfs —which looks like it is the one you made with Genkernel—, and the kernel did boot, but the initramfs has encountered a problem.

I agree.

GDH-gentoo wrote:

Was this different to the previous attempts, or is this what was actually happening the whole time?

No, it was the same.

GDH-gentoo wrote:

Did you see the "Loading Gentoo kernel ..." message that the patched grub.cfg should have printed?

I'm not sure. Unfortunately I cannot reboot right now to tell you. I'll try tomorrow.

GDH-gentoo wrote:

I don't use Genkernel, so unfortunately I can't give advice on how to fix this other than saying that the udev instance cointained in the initramfs seems to be having some kind of trouble.

Before using genkernel, dracut was the first choice. The error message I don't remember, but I remember that dracut run and printed its name. The keyboard then froze.

I bet the problem is in initramfs.
For this reason, I can foresee two options:



    • Recompile kernel without UUID support from kernel;
    • Remove initramfs from /boot;
    • Use /dev/sda2 in /etc/fstab.

    If this works, it is confirmed that the problem is somewhat related to initramfs.
    In this case, I could latter study it more deeply and fix it.
  1. Run genkernel and let it install also the kernel
    If this works, the problem could be with kernel parameters I used in make nconfig.


GDH-gentoo wrote:

...so unfortunately I can't give advice ...

Anyway, I appreciated very much your comments. Thank you!
Back to top
View user's profile Send private message
otaviolb
n00b
n00b


Joined: 28 Nov 2014
Posts: 10

PostPosted: Tue Apr 15, 2025 10:34 pm    Post subject: Reply with quote

flysideways wrote:
A workflow that keeps things simple, is to fully install each distro without any mods on its respective drive, as each distro recommends. Call them A and B.


That is what I did. I installed the kernel binaries, including initramfs.

Now it boots fine!

Before continuing the installation, I intend to investigate what I did wrong, whether with kernel, whether with initramfs.

Anyway, since my initial suspicion was on grub, I can say it did a great job.
The answer is "yes", one grub is enough for two distributions on different disks.

Therefore, this topic can be marked as solved.

Thank you all.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum