grubby is a command line tool for updating and displaying information about the configuration files of various architecture-specific boot programs. It is mainly designed for scripts that install a new kernel and need to find information about the current boot environment, as well as to modify various information parameters for booting the kernel.

This article describes how to use the grubby tool to adjust the kernel boot parameters and boot order in centos8.

The grubby tool can be installed directly using yum or dnf.

1
2
3
4
5
6
$ yum install grubby
Last metadata expiration check: 1:29:38 ago on Wed 18 Nov 2020 09:44:26 AM +08.
Package grubby-8.40-38.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

View the current default boot kernel.

1
2
$ grubby --default-kernel
/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64

View all kernels installed on the system.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$ grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-5.9.1-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.9.1-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64"
index=1
kernel="/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.28.1.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.28.1.el8_2.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.28.1.el8_2.x86_64"
index=2
kernel="/boot/vmlinuz-4.18.0-193.19.1.el8_2.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.19.1.el8_2.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.19.1.el8_2.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.19.1.el8_2.x86_64"
index=3
kernel="/boot/vmlinuz-4.18.0-193.el8.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-4.18.0-193.el8.x86_64.img $tuned_initrd"
title="CentOS Linux (4.18.0-193.el8.x86_64) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.el8.x86_64"
index=4
kernel="/boot/vmlinuz-0-rescue-12ab47b22fef4c02bcdc88b340d5f706"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-0-rescue-12ab47b22fef4c02bcdc88b340d5f706.img"
title="CentOS Linux (0-rescue-12ab47b22fef4c02bcdc88b340d5f706) 8 (Core)"
id="12ab47b22fef4c02bcdc88b340d5f706-0-rescue"

Set the new default boot kernel.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Use path to specify the kernel, you can use --set-default=kernel-path
$ grubby --set-default=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
The default is /boot/loader/entries/12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64.conf with index 0 and kernel /boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
$ grubby --default-kernel
/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64

# Use index to specify the kernel, then use --set-default-index=entry-index
$ grubby --set-default-index=1
The default is /boot/loader/entries/12ab47b22fef4c02bcdc88b340d5f706-4.18.0-193.28.1.el8_2.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64
$ grubby --default-kernel
/boot/vmlinuz-4.18.0-193.28.1.el8_2.x86_64

Add/remove kernel boot parameters.

1
2
3
4
5
6
7
8
# Delete a parameter for all kernels  
$ grubby --update-kernel=ALL --remove-args=intel_iommu=on

# Add a certain parameter to all kernels  
$ grubby --update-kernel=ALL --args=intel_iommu=on

# Add boot parameters to a particular kernel  
$ grubby --update-kernel=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64 --args=intel_iommu=on

View specific information about a particular kernel.

1
2
3
4
5
6
7
8
$ grubby --info=/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64
index=0
kernel="/boot/vmlinuz-5.9.1-1.el8.elrepo.x86_64"
args="ro crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet intel_iommu=on $tuned_params"
root="/dev/mapper/cl-root"
initrd="/boot/initramfs-5.9.1-1.el8.elrepo.x86_64.img $tuned_initrd"
title="Red Hat Enterprise Linux (5.9.1-1.el8.elrepo.x86_64) 8.2 (Ootpa)"
id="12ab47b22fef4c02bcdc88b340d5f706-5.9.1-1.el8.elrepo.x86_64"