Is there a way to make permament change to kernel command line that persists across kernel updates?

When using grubby tool, it will only modify currently installed kernels. Is there a way to make commandline changes persistent across updates?

Thank you

Hello @vladislav, welcome to the Fedora Community

About your question – It is all here in the docs

There’s also this Fedora Magazine article with more info about using grubby:

But I myself usually use add or remove parameters to/from GRUB_CMDLINE_LINUX="..." in /etc/default/grub – as detailed in docs @twohot has linked to. Don’t forget to regenerate grub menu with

grub2-mkconfig -o /path/to/grub.cfg

after making changes to this file.


Thank you, I will try that. I was under impression that since BLS that wouldn’t work, but I’ll try to see if it does.

Editing /etc/default/grub does work with BLS (I do use it), as by default all BLS entries still use GRUB_CMDLINE_LINUX as the default kernel options – unless you change this default manually or with grubby, as far as I understand.

It’s actually quite easy to see. BLS entries are located in /boot/loader/entries, so

less /boot/loader/entries/a97aac0bcaa5464f90fa15026140a8fa-5.4.18-200.fc31.x86_64.conf

gives us:

title Fedora (5.4.18-200.fc31.x86_64) 31 (Thirty One)
version 5.4.18-200.fc31.x86_64
linux /vmlinuz-5.4.18-200.fc31.x86_64
initrd /initramfs-5.4.18-200.fc31.x86_64.img
options $kernelopts
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

options $kernelopts means this BLS entry will use just default options – contained in $kernelopts in grub.cfg I presume – and no special options. So unless we change it manually or with grubby for this BLS entry – it’s be using default from /etc/default/grub.

Actually, I don’t see kernelopts in grub.cfg, but I do see default_kernelopts="..." which contains the line from my /etc/default/grub.

Edit: kernelopts is grub environment variable and is saved in grubenv file (along with other such variables). Although I don’t know exactly when and how it’s derived from GRUB_CMDLINE_LINUX, my guess is it’s done by grub2-mkconfig alongside with grub.cfg – I can be wrong here ) Still I can clearly see on my system that it does correspond to GRUB_CMDLINE_LINUX.

I myself never used grubby to do it (maybe just some testing, can’t remember), so can’t vouch for it personally, but article should be accurate enough too.

1 Like

BLS snippets get boot parameters from GRUB environment variable $kernelopts. This is loaded from grubenv. You can modify grubenv directly.

grub2-editenv list
Then copy/paste kernelopts line as a template, modify as desired, per:
grub2-editenv - set kernelopts="kernel command line"

Yes, that’s a minus symbol, represents the default path to the grubenv.


As it turns out, my grub2 environment file was broken and empty. I recreated it with grub2-editenv create and then added kernelopts value in there together with root specification and other options that I needed. Thank you everyone :slight_smile: I haven’t asked questions on linux forums for maybe 8 years or so and it’s a very positive experience to get such helpful answers.

@vladislav, first of all, glad you’ve resolved your issue, and

– and that’s very heartwarming, thank you) From my own experience people here on Ask Fedora are friendly and helpful )

Just a couple more thoughts.

I haven’t verified all the steps myself, although I’ve used some of them and read about others in discussions here on Ask Fedora.

  • grub2-editenv create creates an empty grubenv file – and helps when you have some kind of trouble with existing file – just as you’ve written.

  • as far as I know – this is one I haven’t verified explicitly – you don’t have to fill it manually. Although you can, of course. ) Some things (like kernelopts) gets filled with grub2-mkconfig, others – after first use of grub (like last boot entry chosen, or was the boot successful or not).

  • and there are some options that you have to set manually (if you need them) with grub2-editenv – like an option not to hide the boot menu even if Fedora is the only OS on the computer:

    sudo grub2-editenv - unset menu_auto_hide

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