Help /etc/default/grub

I mostly make settings through kernel parameters
Is it possible to add multi line(GRUB_CMDLINE_LINUX) for better control parameters?

Like this

GRUB_CMDLINE_LINUX=“parameters”
GRUB_CMDLINE_LINUX=“parameters”
GRUB_CMDLINE_LINUX=“parameters”

Multiple lines of GRUB_CMDLINE_LINUX=“parameters” will be ignored, afaik. Only the first line will work. You have to separate the parameters with a space like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

The difference:

GRUB_CMDLINE_LINUX_DEFAULT="param1 param2" will be executed on every boot.

GRUB_CMDLINE_LINUX="param1 param2" (without the “_DEFAULT”) will NOT be executed if the fall-back kernel is executed.

3 Likes

If you want to just have a better overview of the kernel parameters, something like the following would work.

The example is from my /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="intel_pstate=passive
                            lsm=landlock,lockdown,yama,integrity,apparmor,bpf
                            zswap.enabled=0
                            nowatchdog"
3 Likes

Kind of Off topic, but for future readers:

AFAIK, only the last one will work.

5 Likes

I think you can have multiple lines like this:

GRUB_CMDLINE_LINUX="parameters"
GRUB_CMDLINE_LINUX+=" parameters"
GRUB_CMDLINE_LINUX+=" parameters"

Note the usage of += catenation and the first space inside the additional strings. They should make the value as one bigger string.

Note also that I haven’t really tested this, but AFAIK it is treated as bash or sh script.
Please correct me if I’m wrong.

2 Likes

Are you asking others to test? :rofl: It can be tested with a temporary save to a local file :wink:

The Manual says the same :+1: :

The file /etc/default/grub controls the operation of grub-mkconfig. It is sourced by a shell script, and so must be valid POSIX shell input; normally, it will just be a sequence of ‘KEY=value’ lines, but if the value contains spaces or other special characters then it must be quoted.

2 Likes

→ Are YOU asking others to test??? :rofl:

…or do you know for sure, or did you try it?

1 Like

Why not? :wink:

As it is run with sh, then it should work.
And there are other syntactical ways too:

GRUB_CMDLINE_LINUX="parameters"
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX parameters"
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX parameters"

and the one presented in posts above. And probably more…

So many ways to do the same thing! :sweat_smile:

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.