Linux Commands

How to Add/Remove Kernel Boot Parameters/Arguments and GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

On Fedora 39+, RHEL 9, AlmaLinux 9, Rocky Linux 9, and CentOS Stream 9 Linux distributions, you can use the grubby program to manage the GRUB boot entries.

In this article, we will show you how to use grubby to add/remove the kernel boot parameters from the GRUB boot entries on Fedora, RHEL, AlmaLinux, Rocky Linux, and CentOS Stream. We will also show you how to add/remove the custom GRUB boot entries and set the specific GRUB boot entries as the default using grubby on Fedora, RHEL, AlmaLinux, Rocky Linux, and CentOS Stream.

Topic of Contents:

  1. Listing All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  2. Displaying a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  3. Adding the New Kernel Boot Parameters/Arguments to All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  4. Adding the New Kernel Boot Parameters/Arguments to a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  5. Removing the Kernel Boot Parameters/Arguments from All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  6. Removing the Kernel Boot Parameters/Arguments from a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  7. Adding a GRUB Boot Entry with Custom Kernel Parameters/Arguments on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  8. Setting a GRUB Boot Entry as the Default on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  9. Removing a GRUB Boot Entry from Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  10. Conclusion

Listing All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

To list all the GRUB boot entries of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, run grubby as follows:

$ sudo grubby --info=ALL

As you can see, all the GRUB boot entries (x2) of our CentOS Stream 9 system are listed.

A screenshot of a computer Description automatically generated

Each of the boot entries has:

  1. An index number
  2. The full kernel path
  3. The kernel boot parameters also known as kernel arguments
  4. The full path to the root filesystem
  5. The full path of the “initrd” file
  6. A title for the GRUB boot entry
  7. An ID for the configuration file of this boot entry (can be found in the “/boot/loader/entries/” directory)

A screenshot of a computer Description automatically generated

Displaying a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

You can display an information on a specific GRUB boot entry using grubby on your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system.

To display an information on the default GRUB boot entry, run the following command:

$ sudo grubby --info=DEFAULT

The default GRUB boot entry should be displayed.

A screenshot of a computer program Description automatically generated

You can display an information on the GRUB boot entry at a specific index as well. The index number starts from 0.

To display an information on the first GRUB boot entry (at index 0), run the following command:

$ sudo grubby --info=0

A screenshot of a computer Description automatically generated

In the same way, you can display an information on the second GRUB boot entry (at index 1) with the following command and so on:

$ sudo grubby --info=1

A screenshot of a computer screen Description automatically generated

Adding the New Kernel Boot Parameters/Arguments to All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

To add a kernel boot parameter/argument (let’s say “nomodeset”) to all the GRUB boot entries of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, run the following command:

$ sudo grubby --update-kernel=ALL --args='nomodeset'

To add multiple kernel boot parameters/arguments (“nomodeset” and “nouveau.blacklist=1” for example) to all the GRUB boot entries of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, separate the kernel boot parameters/arguments using spaces as follows:

$ sudo grubby --update-kernel=ALL --args='nomodeset nouveau.blacklist=1'

As you can see, the kernel boot parameters/arguments “nomodeset” and “nouveau.blacklist=1” are added to all the GRUB boot entries.

$ sudo grubby --info=ALL

Adding the New Kernel Boot Parameters/Arguments to a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

To add a kernel boot parameter/argument (“selinux=0” let’s say) to the default GRUB boot entry of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, run the following command:

$ sudo grubby --update-kernel=DEFAULT --args='selinux=0'

To add multiple kernel boot parameters/arguments (“selinux=0” and “ipv6.disable=1” for example) to the default GRUB boot entry of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, separate the kernel boot parameters/arguments using spaces as follows:

$ sudo grubby --update-kernel=DEFAULT --args='selinux=0 ipv6.disable=1'

In the same way, you can add the kernel boot parameters/arguments to the GRUB boot entry at a specific index (index 0 for example) as follows:

$ sudo grubby --update-kernel=0 --args='selinux=0 ipv6.disable=1'

As you can see, the kernel boot parameters/arguments “selinux=0” and “ipv6.disable=1” are added to only the default (index 0) GRUB boot entry.

$ sudo grubby --info=ALL

A screenshot of a computer Description automatically generated

Removing the Kernel Boot Parameters/Arguments from All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

To remove a kernel boot parameter/argument (let’s say “nomodeset”) from all the GRUB boot entries of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, run the following command:

$ sudo grubby --update-kernel=ALL --remove-args='nomodeset'

To remove multiple kernel boot parameters/arguments (“nomodeset” and “nouveau.blacklist=1” for example) from all the GRUB boot entries of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, separate the kernel boot parameters/arguments using spaces as follows:

$ sudo grubby --update-kernel=ALL --remove-args='nomodeset nouveau.blacklist=1'

As you can see, the kernel boot parameters/arguments “nomodeset” and “nouveau.blacklist=1” are removed from all the GRUB boot entries.

$ sudo grubby --info=ALL

A screenshot of a computer Description automatically generated

Removing the Kernel Boot Parameters/Arguments from a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

To remove a kernel boot parameter/argument (let’s say “selinux=0”) from the default GRUB boot entry of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, run the following command:

$ sudo grubby --update-kernel=DEFAULT --remove-args='selinux=0'

To remove multiple kernel boot parameters/arguments (“selinux=0” and “ipv6.disable=1” for example) from the default GRUB boot entry of your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system, separate the kernel boot parameters/arguments using spaces as follows:

$ sudo grubby --update-kernel=DEFAULT --remove-args='selinux=0 ipv6.disable=1'

In the same way, you can remove the kernel boot parameters/arguments from the GRUB boot entry at a specific index (index 0 for example) as follows:

$ sudo grubby --update-kernel=0 --remove-args='selinux=0 ipv6.disable=1'

As you can see, the kernel boot parameters/arguments “selinux=0” and “ipv6.disable=1” are removed from only the default (index 0) GRUB boot entry.

$ sudo grubby --info=DEFAULT

A screenshot of a computer Description automatically generated

Adding a GRUB Boot Entry with Custom Kernel Parameters/Arguments on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

Instead of messing with the factory default GRUB boot entries, at times, it’s best to create a copy of the default GRUB boot entry and modify the kernel parameters/arguments on the copied GRUB boot entry.

To create a copy of the default GRUB boot entry, you need to know the full kernel path and “initrd” path of the default GRUB boot entry.

To find the full kernel path and the “initrd” path of the default GRUB boot entry, run the following command:

$ sudo grubby --info=DEFAULT

The full kernel path[1] and the “initrd” path[2] of the default GRUB boot entry should be displayed. Take note of this information.

A screenshot of a computer Description automatically generated

To create a copy of the default GRUB boot entry using the kernel path and “initrd” path that you found in the output of the earlier command, run the following command:

$ sudo grubby --copy-default \

--add-kernel="/boot/vmlinuz-5.14.0-391.el9.x86_64" \

--initrd="/boot/initramfs-5.14.0-391.el9.x86_64.img $tuned_initrd" \

--title="$(cat /etc/redhat-release) - Disable SELinux - $(uname -r)"

NOTE: Make sure to replace the kernel path and “initrd” path with yours in the “–add-kernel=<kernel-path>” and “–initrd=<initrd-path>” sections, respectively. Also, use a descriptive title for the GRUB boot entry in the “–title=<your-title>” section.

NOTE: In the “–title”, “$(cat /etc/redhat-release)” is replaced by the name of the operating system and version (i.e. CentOS Stream 9) and “$(uname -r)” is replaced by the version number of the currently used Linux kernel (i.e. 5.14.0-391.el9.x86_64).

A new GRUB boot entry should be created.

A screenshot of a computer program Description automatically generated

As you can see, a new GRUB boot entry is created[1] at the index 0[2].

$ sudo grubby --info=ALL

You can use the grubby “–args” option to add the new kernel parameters/arguments and “–remove-args” option to remove the kernel parameters/arguments from the newly created GRUB boot entry (at index 0).

For example, to add the “selinux=0” kernel parameter/argument and remove the “quiet” kernel parameter/argument from the newly created GRUB boot entry (at index 0), run the grubby command as follows:

$ sudo grubby --update-kernel=0 --args="selinux=0" --remove-args="quiet"

As you can see, the “selinux=0” kernel parameter/argument is added and the “quiet” kernel parameter/argument is removed from the newly created GRUB boot entry (at index 0).

$ sudo grubby --info=0

A screenshot of a computer Description automatically generated

Setting a GRUB Boot Entry as the Default on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

Once you created a custom GRUB boot entry, you may want to set it as the default GRUB boot entry of your computer/server so that your computer/server uses it to boot by default.

You can find the index of the default GRUB boot entry with the following command:

$ sudo grubby --default-index

As you can see, the default index is 1.

A black and white text Description automatically generated

The custom GRUB boot entry that we added has the index 0.

To set the custom GRUB boot entry as the default, run the following command:

$ sudo grubby --set-default-index=0

The GRUB boot entry at the index 0 should be set as the default boot entry.

A screenshot of a computer code Description automatically generated

As you can see, the custom GRUB boot entry is set as the default boot entry.

A screenshot of a computer Description automatically generated

The custom GRUB boot entry is automatically selected from the GRUB bootloader.

A screenshot of a computer Description automatically generated

As you can see, the custom GRUB boot entry has all the custom kernel parameters/arguments that we configured.

A screenshot of a computer Description automatically generated

Removing a GRUB Boot Entry from Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

You can remove a GRUB boot entry from your Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream system using grubby as well.

We created a new GRUB boot entry[1] at index 0[1] to demonstrate the procedures of removing a GRUB boot entry using grubby.

A screenshot of a computer Description automatically generated

To remove a GRUB boot entry at index 0, run the following command:

$ sudo grubby --remove-kernel=0

As you can see, the GRUB boot entry is removed and the indices are readjusted.

A screenshot of a computer Description automatically generated

Conclusion

In this article, we showed you how to list the GRUB boot entries using grubby. We also showed you how to add the kernel boot parameters/arguments to the GRUB boot entries and remove the kernel boot parameters/arguments from the GRUB boot entries using grubby. We showed you how to add/remove the custom GRUB boot entries using grubby as well. Finally, we showed you how to set a GRUB boot entry as the default using grubby. The procedures that are shown in this article should work on Fedora, RHEL, AlmaLinux, Rocky Linux, and CentOS Stream operating systems.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.