How to make persistent changes in GRUB2 in Fedora

Updated: September 5, 2019

If you're using Linux, you are also probably, almost definitely, using the GRUB2 bootloader. The bootloader lets you control the startup sequence of the system, especially if you have multiple operating systems installed, like Windows and Linux side by side, multiple distributions of Linux, and so forth. Sometimes, you will need to make changes to the GRUB2 configuration, including specific overrides like kernel command-line parameters.

If the above means nothing to you, you don't need this guide. But if it does, then you can consult my rather extensive GRUB2 tutorial on how to use and manage the bootloader. Except, it's not enough. If you want to add boot parameters to the kernel - permanently - then editing the default configuration file as I've explained in the guide will not work. That's part of the fragmentation delight that's Linux. So we need a different method, and this is why we're here.

How it ought to (have been) done

If only Linux distributions all followed one convention and did everything one way. But since we have multiple package formats, multiple package managers, multiple desktop environments, and multiple distros, then it only makes illogical sense to have multiple bootloaders, or rather just one but peppered with custom tweaks. Thus, Ubuntu and Fedora use different commands and notations to accomplish the same thing.

In Ubuntu et al, you can make kernel command line overrides by appending necessary strings to the GRUB_CMDLINE_LINUX_DEFAULT directive in the /etc/default/grub configuration file. For instance, I've shown you how to do this in my screen brightness and fan control guide for my Asus eeePC netbook. We added a few entries to the file, as follows:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=Linux"

I needed a similar tweak for Fedora 30 when I tested it on my old HP Pavilion machine, which has an Nvidia card, and where I encountered an ugly oops caused by a conflict between the legacy branch of Nvidia drivers (340.xx) and the Spectre patches in the kernel. You can read the full story in the linked distro review above. Bottom line, I needed to append a string, so I did, as I expected GRUB2 to behave. I updated the bootloader configuration file (the Fedora way, see my GRUB2 tutorial updates section), but on next reboot, the option was ignored. There was no desired string under cat /proc/cmdline. I then learned that Fedora does things differently.

Grubby - tool to make persistent GRUB2 changes in Fedora

Yes, you need a tool called grubby, which allows you to append strings to your kernels. Grubby is a command-line tool, and it works by specifying either one desired kernel or all, and then adding the values you want. The downside of this tool is that it is more cumbersome to use than making a configuration file change, you don't know if and how backups are made in case you botch something, and if you add new kernels, they will not have the persistent tweak, and you will have to run it again. Not very elegant. So I ran grubby:

sudo grubby --update-kernel=ALL --args=KERNEL-OPTIONS-GO-HERE

As a specific example, it would look something like (notice the two = signs, not a typo):

sudo grubby --update-kernel=ALL --args=slab_common.usercopy_fallback=Y

I chose to update all kernels, and as the argument, I added the kernel tweak that should stop the conflict between the Nvidia driver and the kernel. To see whether grubby has done its work, or just check the kernel configuration for a particular boot entry, you can run grubby info against the desired kernel version.

sudo grubby --info /boot/vmlinuz-5.0.16-300.fc30.x86_64
args="ro resume=UUID=a43418bb-1d1b-4d1d-81c3-37e1e5bcd3a6 rhgb quiet nouveau.modeset=0 rd.driver.blacklist=nouveau video=vesa:off slab_common.usercopy_fallback=Y"
title="Fedora (5.0.16-300.fc30.x86_64) 30 (Thirty)"

On next boot, I checked the system configuration, and the change was there:

cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos8)/boot/vmlinuz-5.0.16-300.fc30.x86_64 root=UUID=cd1c9a6a-6fb5-44c2-8d68-b4a96ff7f0e9 ro resume=UUID=a43418bb-1d1b-4d1d-81c3-37e1e5bcd3a6 rhgb quiet nouveau.modeset=0 rd.driver.blacklist=nouveau video=vesa:off slab_common.usercopy_fallback=Y


All I can say, I am not happy about this method at all. It's cumbersome, and it goes against what I believe are GRUB conventions. If there's a default configuration, then it should be used, plus it's a single, centralized place where you make changes that affect your system. There's really no reason why there should be a separate tool, plus one that makes tweaks in an opaque way, and is not forward-compatible - new kernels or a GRUB update, what happens then?

Philosophy aside, you have what you came for. If you want to make changes to the kernel command line in Fedora, for whatever reason, grubby is the most convenient way to make a persistent, system-wide change. Of course, you can always test specific, one-time options by editing individual entries at boot-time, and once you're happy they work, make them permanent. Anyway, let's bring this tutorial to a close. Take care.