Chapter 7. Making persistent changes to the GRUB boot loader Use the grubby tool to make persistent changes in GRUB. 7.1. Prerequisites You have successfully installed RHEL on your system. You have root permission. 7.2. Listing the default kernel By listing the default kernel, you can find the file name and the index number of the default kernel to make permanent changes to the GRUB boot loader. Procedure To get the file name of the default kernel, enter: To get the index number of the default kernel, enter: 7.3. Viewing the GRUB menu entry for a kernel You can list all the kernel menu entries or view the GRUB menu entry for a specific kernel. Procedure To list all kernel menu entries, enter: To view the GRUB menu entry for a specific kernel, enter: Note Try tab completion to see available kernels within the /boot directory. 7.4. Editing a Kernel Argument You can change a value in an existing kernel argument. For example, you can change the virtual console (screen) font and size. Procedure Change the virtual console font to latarcyrheb-sun with the size of 32 : 7.5. Adding and removing arguments from a GRUB menu entry You can add, remove, or simultaneously add and remove arguments from the GRUB Menu. Procedure To add arguments to a GRUB menu entry, use the --update-kernel option in combination with --args . For example, following command adds a serial console: The console arguments are attached to the end of the line, the new console will take precedence over any other configured consoles. To remove arguments from a GRUB menu entry, use the --update-kernel option in combination with --remove-args . For example: This command removes the Red Hat graphical boot argument and enables log messages, that is verbose mode. To add and remove arguments simultaneously, enter: Verification To review the permanent changes you have made, enter: 7.6. Adding a new boot entry You can add a new boot entry to the boot loader menu entries. Procedure Copy all the kernel arguments from your default kernel to this new kernel entry: Get the list of available boot entries: Create a new boot entry. For example, for the 4.18.0-193.el8.x86_64 kernel, issue the command as follows: Verification Verify that the newly added boot entry is listed among the available boot entries: 7.7. Changing the default boot entry with grubby With the grubby tool, you can change the default boot entry. Procedure To make a persistent change in the kernel designated as the default kernel, enter: 7.8. Updating all kernel menus with the same arguments You can add the same kernel boot arguments to all the kernel menu entries. Procedure To add the same kernel boot arguments to all the kernel menu entries, attach the --update-kernel=ALL parameter. For example, this command adds a serial console to all kernels: Note The --update-kernel parameter also accepts DEFAULT or a comma-separated list of kernel index numbers. 7.9. Changing default kernel options for current and future kernels By using the kernelopts variable, you can change the default kernel options for both current and future kernels. Procedure List the kernel parameters from the kernelopts variable: Make the changes to the kernel command-line parameters. You can add, remove or modify a parameter. For example, to add the debug parameter, enter: Optional: Verify the parameter newly added to kernelopts : Reboot the system for the changes to take effect. Note As an alternative, you can use the grubby command to pass the arguments to current and future kernels: 7.10. Additional resources The /usr/share/doc/grub2-common directory. The info grub2 command.

Commands:
grubby --default-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --default-index 0
grubby --info=ALL index=0 kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64" args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet USDtuned_params zswap.enabled=1" root="/dev/mapper/rhel-root" initrd="/boot/initramfs-4.18.0-372.9.1.el8.x86_64.img USDtuned_initrd" title="Red Hat Enterprise Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Ootpa)" id="67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64" index=1 kernel="/boot/vmlinuz-0-rescue-67db13ba8cdb420794ef3ee0a8313205" args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet" root="/dev/mapper/rhel-root" initrd="/boot/initramfs-0-rescue-67db13ba8cdb420794ef3ee0a8313205.img" title="Red Hat Enterprise Linux (0-rescue-67db13ba8cdb420794ef3ee0a8313205) 8.6 (Ootpa)" id="67db13ba8cdb420794ef3ee0a8313205-0-rescue"
grubby --info /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 grubby --info /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 index=0 kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64" args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet USDtuned_params zswap.enabled=1" root="/dev/mapper/rhel-root" initrd="/boot/initramfs-4.18.0-372.9.1.el8.x86_64.img USDtuned_initrd" title="Red Hat Enterprise Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Ootpa)" id="67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64"
grubby --args=vconsole.font=latarcyrheb-sun32 --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --args=console=ttyS0,115200 --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --remove-args="rhgb quiet" --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --remove-args="rhgb quiet" --args=console=ttyS0,115200 --update-kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --info /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 index=0 kernel="/boot/vmlinuz-4.18.0-372.9.1.el8.x86_64" args="ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap USDtuned_params zswap.enabled=1 console=ttyS0,115200" root="/dev/mapper/rhel-root" initrd="/boot/initramfs-4.18.0-372.9.1.el8.x86_64.img USDtuned_initrd" title="Red Hat Enterprise Linux (4.18.0-372.9.1.el8.x86_64) 8.6 (Ootpa)" id="67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64"
grubby --add-kernel=new_kernel --title="entry_title" --initrd="new_initrd" --copy-default
ls -l /boot/loader/entries/ * -rw-r--r--. 1 root root 408 May 27 06:18 /boot/loader/entries/67db13ba8cdb420794ef3ee0a8313205-0-rescue.conf -rw-r--r--. 1 root root 536 Jun 30 07:53 /boot/loader/entries/67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64.conf -rw-r--r-- 1 root root 336 Aug 15 15:12 /boot/loader/entries/d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.el8.x86_64.conf
grubby --grub2 --add-kernel=/boot/vmlinuz-4.18.0-193.el8.x86_64 --title="Red Hat Enterprise 8 Test" --initrd=/boot/initramfs-4.18.0-193.el8.x86_64.img --copy-default
ls -l /boot/loader/entries/ * -rw-r--r--. 1 root root 408 May 27 06:18 /boot/loader/entries/67db13ba8cdb420794ef3ee0a8313205-0-rescue.conf -rw-r--r--. 1 root root 536 Jun 30 07:53 /boot/loader/entries/67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64.conf -rw-r--r-- 1 root root 287 Aug 16 15:17 /boot/loader/entries/d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.el8.x86_64.0~custom.conf -rw-r--r-- 1 root root 287 Aug 16 15:29 /boot/loader/entries/d88fa2c7ff574ae782ec8c4288de4e85-4.18.0-193.el8.x86_64.conf
grubby --set-default /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 The default is /boot/loader/entries/67db13ba8cdb420794ef3ee0a8313205-4.18.0-372.9.1.el8.x86_64.conf with index 0 and kernel /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
grubby --update-kernel=ALL --args=console=ttyS0,115200
grub2-editenv - list | grep kernelopts kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet
grub2-editenv - set "USD(grub2-editenv - list | grep kernelopts) < debug >"
grub2-editenv - list | grep kernelopts kernelopts=root=/dev/mapper/rhel-root ro crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet debug
grubby --update-kernel ALL --args="< PARAMETER >"