Chapter 4. Configuring kernel command-line parameters
With kernel command-line parameters, you can change the behavior of certain aspects of the Red Hat Enterprise Linux kernel at boot time. As a system administrator, you control which options get set at boot. Note that certain kernel behaviors can only be set at boot time.
Changing the behavior of the system by modifying kernel command-line parameters can have negative effects on your system. Always test changes before deploying them in production. For further guidance, contact Red Hat Support.
4.1. What are kernel command-line parameters
With kernel command-line parameters, you can overwrite default values and set specific hardware settings. At boot time, you can configure the following features:
- The Red Hat Enterprise Linux kernel
- The initial RAM disk
- The user space features
By default, the kernel command-line parameters for systems using the GRUB boot loader are defined in the boot entry configuration file for each kernel boot entry.
You can manipulate boot loader configuration files by using the grubby
utility. With grubby
, you can perform these actions:
- Change the default boot entry.
- Add or remove arguments from a GRUB menu entry.
4.2. Understanding boot entries
A boot entry is a collection of options stored in a configuration file and tied to a particular kernel version. In practice, you have at least as many boot entries as your system has installed kernels. The boot entry configuration file is located in the /boot/loader/entries/
directory:
d8712ab6d4f14683c5625e87b52b6b6e-6.12.0.el10_0.x86_64.conf
d8712ab6d4f14683c5625e87b52b6b6e-6.12.0.el10_0.x86_64.conf
The file name consists of a machine ID stored in the /etc/machine-id
file, and a kernel version.
The boot entry configuration file contains information about the kernel version, the initial ramdisk image, and the kernel command-line parameters. The example contents of a boot entry config can be seen below:
title Red Hat Enterprise Linux (6.12.0-0.el10_0.x86_64) 10.0 version 6.12.0-0.el10_0.x86_64 linux /vmlinuz-6.12.0-0.el10_0.x86_64 initrd /initramfs-6.12.0-0.el10_0.x86_64.img options root=/dev/mapper/rhel_kvm--02--guest08-root ro crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel_kvm--02--guest08-swap rd.lvm.lv=rhel_kvm-02-guest08/root rd.lvm.lv=rhel_kvm-02-guest08/swap console=ttyS0,115200 grub_users $grub_users grub_arg --unrestricted grub_class kernel
title Red Hat Enterprise Linux (6.12.0-0.el10_0.x86_64) 10.0
version 6.12.0-0.el10_0.x86_64
linux /vmlinuz-6.12.0-0.el10_0.x86_64
initrd /initramfs-6.12.0-0.el10_0.x86_64.img
options root=/dev/mapper/rhel_kvm--02--guest08-root ro crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel_kvm--02--guest08-swap rd.lvm.lv=rhel_kvm-02-guest08/root rd.lvm.lv=rhel_kvm-02-guest08/swap console=ttyS0,115200
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
4.3. Changing kernel command-line parameters for all boot entries
Change kernel command-line parameters for all boot entries on your system.
When installing a newer version of the kernel in Red Hat Enterprise Linux 10 systems, the grubby
tool passes the kernel command-line arguments from the previous kernel version.
Prerequisites
-
grubby
utility is installed on your system. -
zipl
utility is installed on your IBM Z system.
Procedure
To add a parameter:
grubby --update-kernel=ALL --args="<NEW_PARAMETER>"
# grubby --update-kernel=ALL --args="<NEW_PARAMETER>"
Copy to Clipboard Copied! For systems that use the GRUB boot loader and, on IBM Z that use the zIPL boot loader, the command adds a new kernel parameter to each
/boot/loader/entries/<ENTRY>.conf
file.On IBM Z, update the boot menu:
zipl
# zipl
Copy to Clipboard Copied!
To remove a parameter:
grubby --update-kernel=ALL --remove-args="<PARAMETER_TO_REMOVE>"
# grubby --update-kernel=ALL --remove-args="<PARAMETER_TO_REMOVE>"
Copy to Clipboard Copied! On IBM Z, update the boot menu:
zipl
# zipl
Copy to Clipboard Copied! NoteThere is no need to update boot menu for the systems using the GRUB boot loader.
4.4. Changing kernel command-line parameters for a single boot entry
Make changes in kernel command-line parameters for a single boot entry on your system.
Prerequisites
-
grubby
andzipl
utilities are installed on your system.
Procedure
To add a parameter:
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="<NEW_PARAMETER>"
# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="<NEW_PARAMETER>"
Copy to Clipboard Copied! On IBM Z, update the boot menu:
zipl
# zipl
Copy to Clipboard Copied!
To remove a parameter:
grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="<PARAMETER_TO_REMOVE>"
# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="<PARAMETER_TO_REMOVE>"
Copy to Clipboard Copied! On IBM Z, update the boot menu:
zipl
# zipl
Copy to Clipboard Copied!
-
grubby
modifies and stores the kernel command-line parameters of an individual kernel boot entry in the/boot/loader/entries/<ENTRY>.conf
file.
4.5. Changing kernel command-line parameters temporarily at boot time
Make temporary changes to a Kernel Menu Entry by changing the kernel parameters only during a single boot process.
This procedure applies only for a single boot and does not persist after system reboot.
Procedure
- Boot into the GRUB boot menu.
- Select the kernel you want to start.
- Press the e key to edit the kernel parameters.
- Find the kernel command line by moving the cursor down.
Move the cursor to the end of the line.
NotePress Ctrl+a to jump to the start of the line and Ctrl+e to jump to the end of the line. On some systems, Home and End keys might also work.
Edit the kernel parameters as required. For example, to run the system in emergency mode, add the
emergency
parameter at the end of thelinux
line:linux ($root)/vmlinuz-6.12.0-0.el10_0.x86_64 root=/dev/mapper/rhel-root ro crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet emergency
linux ($root)/vmlinuz-6.12.0-0.el10_0.x86_64 root=/dev/mapper/rhel-root ro crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet emergency
Copy to Clipboard Copied! To enable the system messages, remove the
rhgb
andquiet
parameters.- Press Ctrl+x to boot with the selected kernel and the modified command line parameters.
If you press the Esc key to leave command line editing, it will drop all the user made changes.
4.6. Configuring GRUB settings to enable serial console connection
The serial console is beneficial when you need to connect to a headless server or an embedded system and the network is down. Or, when you need to avoid security rules and obtain login access on a different system.
You need to configure some default GRUB settings to use the serial console connection.
Prerequisites
- You have root permissions on the system.
Procedure
Add the following two lines to the
/etc/default/grub
file:GRUB_TERMINAL="serial" GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"
GRUB_TERMINAL="serial" GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"
Copy to Clipboard Copied! The first line disables the graphical terminal. The
GRUB_TERMINAL
key overrides values ofGRUB_TERMINAL_INPUT
andGRUB_TERMINAL_OUTPUT
keys.The second line adjusts the baud rate (
--speed
), parity and other values to fit your environment and hardware. Note that a higher baud rate, for example 115200, is preferable for tasks such as following log files.Update the GRUB configuration file:
grub2-mkconfig -o /boot/grub2/grub.cfg
# grub2-mkconfig -o /boot/grub2/grub.cfg
Copy to Clipboard Copied! This applies to both, BIOS and UEFI based machines.
- Reboot the system for the changes to take effect.
4.7. Changing boot entries with the GRUB configuration file
The /etc/default/grub
GRUB configuration file contains the GRUB_CMDLINE_LINUX
key, which lists kernel command-line arguments to add to boot entries for the Linux kernel. For example:
GRUB_CMDLINE_LINUX="crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap"
GRUB_CMDLINE_LINUX="crashkernel=2G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap"
To change the boot entries, overwrite Boot Loader Specification (BLS) snippets with the contents of the GRUB_CMDLINE_LINUX
values.
Prerequisites
- A fresh Red Hat Enterprise Linux 10 installation.
Procedure
Add or remove a kernel parameter for individual kernels in a post installation script with
grubby
:grubby --update-kernel <PATH_TO_KERNEL> --args "<NEW_ARGUMENTS>"
# grubby --update-kernel <PATH_TO_KERNEL> --args "<NEW_ARGUMENTS>"
Copy to Clipboard Copied! For example, add the
noapic
parameter to the chosen kernel:grubby --update-kernel /boot/vmlinuz-6.12.0-0.el10_0.x86_64 --args "noapic"
# grubby --update-kernel /boot/vmlinuz-6.12.0-0.el10_0.x86_64 --args "noapic"
Copy to Clipboard Copied! The parameter is propagated into the BLS snippets, but not into the
/etc/default/grub
file.Overwrite BLS snippets with the contents of the
GRUB_CMDLINE_LINUX
values present in the/etc/default/grub
file:grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline
# grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline Generating grub configuration file … Adding boot menu entry for UEFI Firmware Settings … done
Copy to Clipboard Copied! NoteOther changes, such as changes made to
GRUB_TIMEOUT
key (also included in the/etc/default/grub
GRUB configuration file) are propagated to the newgrub.cfg
file by executinggrub2-mkconfig
command.
Verification
- Reboot your system.
Verify that the parameters are included in the
/proc/cmdline
file.For example, if you added the
noapic
:BOOT_IMAGE=(hd0,gpt2)/vmlinuz-6.12.0-0.el10_0.x86_64 root=/dev/mapper/RHELCSB-Root ro vconsole.keymap=us crashkernel=2G-64G:256M,64G-:512M rd.lvm.lv=RHELCSB/Root rd.luks.uuid=luks-d8a28c4c-96aa-4319-be26-96896272151d rhgb quiet noapic rd.luks.key=d8a28c4c-96aa-4319-be26-96896272151d=/keyfile:UUID=c47d962e-4be8-41d6-8216-8cf7a0d3b911 ipv6.disable=1
BOOT_IMAGE=(hd0,gpt2)/vmlinuz-6.12.0-0.el10_0.x86_64 root=/dev/mapper/RHELCSB-Root ro vconsole.keymap=us crashkernel=2G-64G:256M,64G-:512M rd.lvm.lv=RHELCSB/Root rd.luks.uuid=luks-d8a28c4c-96aa-4319-be26-96896272151d rhgb quiet noapic rd.luks.key=d8a28c4c-96aa-4319-be26-96896272151d=/keyfile:UUID=c47d962e-4be8-41d6-8216-8cf7a0d3b911 ipv6.disable=1
Copy to Clipboard Copied!