Home > Article > Computer Tutorials > How to add/remove kernel boot parameters/parameters and GRUB boot script on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams
On Fedora 39, RHEL 9, AlmaLinux 9, Rocky Linux 9, and CentOS Stream 9 Linux distributions, you can use the grubby program to manage GRUB boot entries.
In this article, we will show you how to use GRUBY to add/remove kernel boot parameters from the GRUB boot entry on Fedora, RHEL, AlmaLinux, Rocky Linux and CentOS Stream. We will also show you how to add/remove customized GRUB boot entries and set specific GRUB boot entries as default using GRUBY on Fedora, RHEL, AlmaLinux, Rocky Linux, and CentOS Stream.
To list all GRUB boot entries for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streaming systems, run grubby as follows:
$sudo grubby --info = ALL
As you can see, all GRUB boot entries (X2) for the CentOS Stream 9 system are listed.
Each boot entry has:
You can use GRUBY to display information about specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems.
To display information about the default GRUB boot entry, run the following command:
$sudo grubby --info=default
The default GRUB boot entry should be displayed.
You can also display information about GRUB boot entries at a specific index. Index numbers start from 0.
To display information about the first GRUB boot entry (at index 0), run the following command:
$sudo grubby——info=0
Similarly, you can use the following command to display information for the second GRUB boot entry (at index 1), and so on:
$sudo grubby——info=1
To add a kernel boot parameter/parameter (such as "nomodeset") to all GRUB boot entries in Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems, run the following command:
$sudo gRUBY–UPDATE-KERNEL=all–args=‘noodeset’
To add multiple kernel boot arguments/parameters (e.g. "onomodeset" and "nouveau.Blacklist=1") to all GRUB boot entries for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems, separate them with spaces Kernel boot parameters/parameters as follows:
$sudo grubby——update—core = ALL——args =’nomodeset nouveau. blacklist = 1 ‘
As you can see, the kernel boot parameters/parameters "nomodeset" and "nouveau.blacklist = 1" are added to all GRUB boot entries.
$sudo grubby --info = ALL
To add kernel boot parameters/arguments (such as "selinux=0") to the default GRUB boot entry of Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems, please run the following command:
$sudo grubby --update-core=default --args='selinux=0 '
To add multiple kernel boot parameters/parameters (such as "selinux=0" and "ipv6.disable=1") to the default GRUB boot entry for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streaming systems, please Use spaces to separate kernel boot arguments/parameters like this:
$sudo gRUBY–UPDATE-KERNEL=DEFAULT–args=‘selinux=0 ipv6.able=1’
Similarly, you can add kernel boot parameters/parameters to the GRUB boot entry at a specific index (e.g. index 0) like this:
$sudo grubby——update—core=0——args=’selinux=0 ipv6.disable=1 ‘
As you can see, the kernel boot parameters/parameters "selinux=0" and "ipv6.disable=1" are only added to the default (index 0) GRUB boot entry.
$sudo grubby --info = ALL
To remove kernel boot parameters/parameters (such as "nomodeset") from all GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streaming systems, run the following command:
$sudo grubby——update—core = ALL——remove—args =’nomodeset ‘
To remove multiple kernel boot arguments/parameters (such as "onomodeset" and "nouveau.Blacklist=1") from all GRUB boot entries for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems, separate them with spaces Kernel boot parameters/parameters as follows:
$sudo grubby——update—core = ALL——remove—args =’nomodeset nouveau. blacklist = 1 ‘
As you can see, the kernel boot parameters/parameters "nomodeset" and "nouveau.blacklist=1" are removed from all GRUB boot entries.
$sudo grubby --info = ALL
To remove kernel boot parameters/parameters from the default GRUB boot entry for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streaming systems (assuming "selinux = 0"), run the following command:
$sudo grubby——update—core=Default——remove—args=’selinux=0 ‘
To remove multiple kernel boot parameters/parameters (such as "selinux=0" and "ipv6.disable=1") from the default GRUB boot entry for Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streaming systems, use Space separated kernel boot arguments/arguments as follows:
$sudo grubby --update-core=default --remove-args='selinux=0 ipv6.disable=1 '
Similarly, you can remove kernel boot parameters/parameters from the GRUB boot entry at a specific index (e.g. index 0) as follows:
$sudo grubby——update—core=0——remove—args=’selinux=0 ipv6.disable=1 ‘
As you can see, the kernel boot parameters/parameters "selinux=0" and "ipv6.able=1" are only removed from the default (index 0) GRUB boot entry.
$sudo grubby --info=default
Sometimes, it is better to create a copy of the default GRUB boot entry and modify the kernel parameters/parameters on the copied GRUB boot entry rather than destroying the factory default 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 complete 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 "initrd" path [2] of the default GRUB boot entry should be displayed. Please pay attention to this information.
To create a copy of the default GRUB boot entry using the kernel path and "initrd" path found in the output of the previous command, run the following command:
$sudo grubby——copy—default
——add—core=”/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: Please make sure to replace the kernel path and "initrd" path with the paths in the "-add-core=" and "-initrd=" sections respectively. Additionally, use a descriptive title for the GRUB boot entry in the "-title=" section.
Note: In "-title", "$(cat/etc/redhat-release)" is replaced by the operating system and version name (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 [1] was created at index 0 [2].
$sudo grubby --info = ALL
You can use grubby "--args" option to add new kernel parameters/parameters, and use "--remove-args" option to remove kernel parameters/parameters from the newly created GRUB boot entry (at index 0).
For example, to add the "selinux = 0" kernel parameter/parameter and remove the "quiet" kernel parameter/parameter from the newly created GRUB boot entry (at index 0), run the grubby command as follows:
$sudo grubby --update-core=0 --args="selinux=0" --remove-args="quiet"
As you can see, the "selinux=0" kernel parameter/parameter is added and the "quiet" kernel parameter/parameter is removed from the newly created GRUB boot entry (at index 0).
$sudo grubby——info=0
After you create a custom GRUB boot entry, you may want to set it as the default GRUB boot entry for your computer/server so that your computer/server boots with it by default.
You can find the index of the default GRUB boot entry using the following command:
$sudo grubby——default—index
As you can see, the default index is 1.
The index of the custom GRUB boot entry we added is 0.
To set a custom GRUB boot entry as the default, run the following command:
$sudo gRubby–set-default-index=0
The GRUB boot entry at index 0 should be set as the default boot entry.
As you can see, the customized GRUB boot entry is set as the default boot entry.
Customized GRUB boot items are automatically selected from the GRUB boot loader.
As you can see, the custom GRUB boot entry contains all the custom kernel parameters/parameters we configured.
You can also use GRUBY to delete GRUB boot entries from Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream systems.
We created a new GRUBboot entry [1] at index 0 [1] to demonstrate the process of removing GRUBboot entry using grubby.
To delete the GRUB boot entry at index 0, run the following command:
$sudo grubby——remove—core = 0
As you can see, the GRUB boot entry was removed and the index was resized.
In this article, we show you how to list GRUB boot entries using grubby. We also showed you how to use grubby to add kernel boot parameters/parameters to a GRUB boot entry, and how to use grubby to remove kernel boot parameters/parameters from a GRUB boot entry. We also show you how to add/remove custom GRUB boot entries using grubby. Finally, we showed you how to use grubby to set a GRUB boot entry as the default. The process shown in this article should work on Fedora, RHEL, AlmaLinux, Rocky Linux and CentOS Stream operating systems.
The above is the detailed content of How to add/remove kernel boot parameters/parameters and GRUB boot script on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams. For more information, please follow other related articles on the PHP Chinese website!