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:
- Listing All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Displaying a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Adding the New Kernel Boot Parameters/Arguments to All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Adding the New Kernel Boot Parameters/Arguments to a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Removing the Kernel Boot Parameters/Arguments from All GRUB Boot Entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Removing the Kernel Boot Parameters/Arguments from a Specific GRUB Boot Entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Adding a GRUB Boot Entry with Custom Kernel Parameters/Arguments on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Setting a GRUB Boot Entry as the Default on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- Removing a GRUB Boot Entry from Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
- 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:
As you can see, all the GRUB boot entries (x2) of our CentOS Stream 9 system are listed.
Each of the boot entries has:
- An index number
- The full kernel path
- The kernel boot parameters also known as kernel arguments
- The full path to the root filesystem
- The full path of the “initrd” file
- A title for the GRUB boot entry
- An ID for the configuration file of this boot entry (can be found in the “/boot/loader/entries/” directory)
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:
The default GRUB boot entry should be displayed.
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:
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:
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:
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:
As you can see, the kernel boot parameters/arguments “nomodeset” and “nouveau.blacklist=1” are added to all the GRUB boot entries.
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:
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:
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:
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.
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:
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:
As you can see, the kernel boot parameters/arguments “nomodeset” and “nouveau.blacklist=1” are removed from all the GRUB boot entries.
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:
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:
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:
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.
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:
The full kernel path[1] and the “initrd” path[2] of the default GRUB boot entry should be displayed. Take note of this information.
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:
--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.
As you can see, a new GRUB boot entry is created[1] at the index 0[2].
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:
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).
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:
As you can see, the default index is 1.
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:
The GRUB boot entry at the index 0 should be set as the default boot entry.
As you can see, the custom GRUB boot entry is set as the default boot entry.
The custom GRUB boot entry is automatically selected from the GRUB bootloader.
As you can see, the custom GRUB boot entry has all the custom kernel parameters/arguments that we configured.
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.
To remove a GRUB boot entry at index 0, run the following command:
As you can see, the GRUB boot entry is removed and the indices are readjusted.
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.