Home  >  Article  >  Computer Tutorials  >  How to add/remove kernel boot parameters/parameters and GRUB boot script on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams

How to add/remove kernel boot parameters/parameters and GRUB boot script on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams

PHPz
PHPzforward
2024-03-20 17:36:241199browse

如何在Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS流上添加/删除内核引导参数/参数和GRUB引导脚本

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.

Content topic:

  1. All GRUBboot on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  2. Display specific GRUB boot items on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  3. Add new kernel boot arguments/parameters to all GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  4. Add new kernel boot arguments/parameters to specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams
  5. Remove kernel boot parameters/parameters from all GRUBBoot NTFS on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams
  6. Remove kernel boot parameters/parameters from specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  7. Add GRUB boot entry with custom kernel parameters/parameters on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  8. Set the GRUB boot entry as the default entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream
  9. Remove a GRUB boot entry from the Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS stream
  10. in conclusion

All GRUBboot on Fedora/RHEL/AlmaLinux/Rocky Linux/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:

  1. The index number
  2. Full kernel path
  3. Kernel boot parameters are also called kernel parameters
  4. Full path to the root file system
  5. Full path to "initrd" file
  6. Title of GRUB boot entry
  7. The ID of the configuration file for this boot entry (can be found in the "/ot/loader/entry/" directory)

Display specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

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

Add new kernel boot arguments/parameters to all GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

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

Add new kernel boot arguments/parameters to specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams

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

Remove kernel boot parameters/parameters from all GRUBBoot NTFS on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS streams

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

Remove kernel boot parameters/parameters from specific GRUB boot entries on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

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

Add GRUB boot entry with custom kernel parameters/parameters on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

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

Set the GRUB boot entry as the default entry on Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS Stream

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.

Remove a GRUB boot entry from the Fedora/RHEL/AlmaLinux/Rocky Linux/CentOS stream

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 conclusion

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!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete