Multiboot: setting grub parameters

I learnt something about grub today.
Say we have 2 Linux distros, A and B , with grub configured to multiboot.
Let distro A be the controller of grub. So A has grub installed and has a /boot/grub/grub.cfg file produced by running
update-grub ( and os-prober). B may have no grub installed at all, and èven if it has grub, it may have no /boot/grub/grub.cfg
file.
Now lets say I want to set a linux boot parameter for B… I go to /etc/default/grub in B and add a line
GRUB_CMDLINE_LINUX="init=/sbin/runit-init"
Then I go to Linux A and run update-grub
Then I reboot back to Linux B, and it does not have the new
linux commandline parameter. Why?
I always assumed that update-grub in Linux A would probe
the etc/default/grub file in Linux B, and set the new boot parameter. It does not !!!

So how can I get update-grub in Linux A to see the new boot parameter that I set in Linux B?
What I had to do was

  • install grub in Linux B ( Gentoo does not have grub by default)
  • run update-grub in Linux B… ie make a /boot/grub/grub.cfg
    file in Linux B ( actually used mkconfig -o /boot/grub/grub.cfg
    because Gentoo does not have update-grub).
  • then go back to Linux A and run update-grub
  • then boot Linux B, and it has the new Linux cmdline parameter.

So what is going on?
It seems os-prober does not look at /etc/default/grub at all. It looks at /boot/grub/grub.cfg… so you have to make one
for any changes in parameters to be seen.

Is it really true that in a multiboot setup , one has to make a
grub.cfg file in every distro ( ie not only in the distro controlling grub) , just so that os-prober can see the grub parameters for each distro?

This seems crazy. Tell me if I am wrong? I would like it to be simpler than that.

2 Likes

@nevj
With multi boot distros, on the same disk, the distro would have to have os-prober installed and enabled, in order to find other distros. The distro you wish to boot will need to be controlled by "GRUB_DEFAULT=0 or the # at what your distro has
Grub
If I had more than one distro booting, then count down, in the grub boot menu and enter the # you want for GRUB_DEFAULT=0 or 1 or 2 or 3.
So update-grub or grub-mkconfig can only find what grub is installed or use a super boot grub dvd that finds and boots the vmlinuz for the installed distro.

5 Likes

Hi Neville, :wave:

this is an interesting topic.

I have some additional questions:

  • are your 2 Linux distros installed on the same disk?
  • would it make any difference if Linux A and Linux B were installed on 2 different disks?

Many greetings from Rosika :slightly_smiling_face:

1 Like

In my case the 2 distros were on the same disk.
It would not make any difference if the 2 distros were on
separate disks, os-prober searches every disk on the machine, even a USB flash drive, if you have one plugged in.

1 Like

You mean update-grub in Linux A can only find grub parameters in Linux B, if Linux B has grub.cfg file containing those parameters,
That is what I found. It surprised me.

@nevj
What is in your grub menu, when you first boot? Is linux A and linux B both in your grub menu?

1 Debian
2 Gentoo
3 a loop mounted iso file of Void

That is all OK. I am only talking about setting a linux cmdline
parameter for Gentoo.
I can do it by editing the Gentoo entry on the grub menu …that is fine
but
if I try to set it in etc/default/grub in Gentoo, update-grub in Debian does not see it. I have to do update-grub in Gentoo first.

What does GRUB_DEFAUT= in Gentoo?

I will have to look.

nevj@mary /etc/default $ cat grub
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#
# To populate all changes in this file you need to regenerate your
# grub configuration file afterwards:
#     'grub-mkconfig -o /boot/grub/grub.cfg'
#
# See the grub info page for documentation on possible variables and
# their associated values.

GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
#GRUB_DEFAULT=0

# Boot the default entry this many seconds after the menu is displayed
#GRUB_TIMEOUT=5
#GRUB_TIMEOUT_STYLE=menu

# Append parameters to the linux kernel command line
#GRUB_CMDLINE_LINUX=""
#
# Examples:
#
# Boot with network interface renaming disabled
# GRUB_CMDLINE_LINUX="net.ifnames=0"
#
# Boot with systemd instead of sysvinit (openrc)
# GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"
#
# Boot with runit instead of sysvinit
GRUB_CMDLINE_LINUX="init=/sbin/runit-init"

# Append parameters to the linux kernel command line for non-recovery entries
#GRUB_CMDLINE_LINUX_DEFAULT=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# 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=640x480

# Set to 'text' to force the Linux kernel to boot in normal text
# mode, 'keep' to preserve the graphics mode set using
# 'GRUB_GFXMODE', 'WIDTHxHEIGHT'['xDEPTH'] to set a particular
# graphics mode, or a sequence of these separated by commas or
# semicolons to try several modes in sequence.
#GRUB_GFXPAYLOAD_LINUX=

# Path to theme spec txt file.
# The starfield is by default provided with use truetype.
# NOTE: when enabling custom theme, ensure you have required font/etc.
#GRUB_THEME="/boot/grub/themes/starfield/theme.txt"

# Background image used on graphical terminal.
# Can be in various bitmap formats.
#GRUB_BACKGROUND="/boot/grub/mybackground.png"

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

# Comment if you don't want GRUB to pass "root=PARTUUID=xxx" parameter to kernel
GRUB_DISABLE_LINUX_PARTUUID=false

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=true

# Uncomment to disable generation of the submenu and put all choices on
# the top-level menu.
# Besides the visual affect of no sub menu, this makes navigation of the
# menu easier for a user who can't see the screen.
#GRUB_DISABLE_SUBMENU=y

# Uncomment to play a tone when the main menu is displayed.
# This is useful, for example, to allow users who can't see the screen
# to know when they can make a choice on the menu.
#GRUB_INIT_TUNE="60 800 1"
nevj@mary /etc/default $ 

GRUB_DEFAULT is commented out

the critical thing I want debians update-grub to see is

GRUB_CMDLINE_LINUX="init=/sbin/runit-init"

that tells it to boot Gentoo with runit instead of OpenRC init.

2 Likes

So if you use grub-mkconfig -o /boot/grub/grub.cfg command with Gentoo, it will find Debian and Void?

I dont need it to find Debian or Void. Gentoo does not control grub. I just need it to make the grub.cfg file in Gentoo, so that
when I update-grub in Debian it can see the boot parameter for Gentoo.

Then you are wanting Debian grub to find Gentoo and Void?

Yes. It finds them OK.
It just does not read the /etc/default/grub file in Gentoo
it reads grub.cfg in Gentoo
so I have to make grub.cfg in Gentoo BEFORE I run update-grub in Debian.

Dont worry, I was confused too.

I have ran into this issue before when tying to boot Gentoo and Arch with Debian based distros. Less headache if I just used Gentoo to control grub and changed GRUB_DEFAULT=# or saved and the GRUB_SAVEDEFAULT=true.

@Daniel_Phillips ,
I think it comes down to this.
Lets say there is only one distro
If I change something in /etc/default/grub
do I have to run update-grub for it to take effect.?
or
does it depend on which parameter I change

I can see that if I change GRUB_CMDLINE_LINUX=…, it would need to remake grub.cfg but if I just change GRUB_TIMEOUT=… I think
that should take effect without remaking grub.cfg.

What do you think?

Any change that is made in /etc/defaut/grub has to have update-grub ran!!! GRUB_DEFAULT=0 can be changed and implemented on a reboot.

2 Likes

OK, that is what I missed.
What is confusing is , if I change /etc/default/grub in Gentoo, which does not control grub, I still have to run update-grub in Gentoo to make a new grub.cfg in Gentoo, even though it does not use it to make the grub menu.
Then, after doing that , I have to make the grub menu with Debian.

because
os-prober looks at grub.cfg in each distro… it does not look at
/etc/default/grub.

Thanks, I feel confident again now.

BTW I have Gentoo booting with runit

nevj@mary ~ $ ps ax | grep run
    1 ?        Ss     0:00 runit
 2590 ?        Ss     0:00 runsvdir -P /etc/service log: ...........................................................................................................................................................................................................................................................................................................................................................................................................
 2591 ?        Ss     0:00 runsv getty-tty5
 2592 ?        Ss     0:00 runsv getty-tty3
 2593 ?        Ss     0:00 runsv getty-tty6
 2594 ?        Ss     0:00 runsv getty-tty4
 2595 ?        Ss     0:00 runsv getty-tty2
 2596 ?        Ss     0:00 runsv getty-tty1

See, process #1 is runit, not init.
It is only controlling gettys at this stage, other services are still
OpenRc.

3 Likes

That is why I always used Gentoo with mult boots of linux on the same disk.

I recently made an ISO in System-Back, which does not support UEFI. Said ISO is a customed Xubuntu 22.04, without Snaps, which is getting harder and harder to uninstall on a Ubuntu family Distro. Anyway. To get it to boot from USB I had to change my bios to Legacy/UEFI option instead of the usual just plain UEFI. After installation, had to go back into my mint 21.2 install on my main separate SSD, updated Grub and it found Xubuntu 22.04. Booted back into Xubuntu install on other SSD and Legacy cannot read UEFI installations, that is what I’m led to believe. Still I think it is safer this way round, as using UEFI boot is still risky

I have found similar issues when having multiboot. First I tried to use Debian for booting the grub menu with entries to Debian, Void, Arch and Gentoo. Every time there was any update in those rolling distroes (like kernel/grub) I needed to update the grub on the OS which got an update and also on Debian (OS-prober enabled). It didn’t always work so I installed rEFInd and use it. Every distro has its own boot partition. I find it easier this way. Just need to first select OS to boot and then it starts it’s grub menu.