Chapter 77. Configuring kernel command line parameters

As a system administrator, you can configure the kernel command line parameters to ensure that they are set and loaded as soon as possible. Also, certain kernel command line parameters are only adjustable in this way.

Important

Be careful when configuring kernel command line parameters on a production system. Haphazard changes may render the kernel unstable, and could cause the system to fail to boot on reboot for all kernels. For this reason, be knowledgeable and sure that you are using the valid options before attempting to change any values.

77.1. What are boot entries

A boot entry is a collection of options forming together a configuration file, which is usually 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 and can look like this:

6f9cc9cb7d7845d49698c9537337cedc-4.18.0-5.el8.x86_64.conf

The file name above consists of a machine ID stored in the /etc/machine-id file, and a kernel version.

The boot entry configuration file carries, among others, information about kernel version, initial ramdisk image, and the kernelopts variable, which contains kernel command line parameters. The contents of a boot entry config can be seen below:

title Red Hat Enterprise Linux (4.18.0-74.el8.x86_64) 8.0 (Ootpa)
version 4.18.0-74.el8.x86_64
linux /vmlinuz-4.18.0-74.el8.x86_64
initrd /initramfs-4.18.0-74.el8.x86_64.img $tuned_initrd
options $kernelopts $tuned_params
id rhel-20190227183418-4.18.0-74.el8.x86_64
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

77.2. What are kernel command line parameters

This module explains the concept of kernel command line parameters and their role in the system administration.

The kernel command line parameters, also known as kernel arguments, are used for boot time configuration of:

  • The Linux kernel
  • The initial RAM disk
  • The user space features

The kernel command line parameters are often used to overwrite the default values and for informing the kernel about hardware parameters where the kernel would have problems to obtain such information.

By default, the kernel command line parameters for systems using the GRUB2 bootloader are defined in the kernelopts variable of the /boot/grub2/grubenv file for all kernel boot entries.

Note

For IBM Z, the kernel command line parameters are stored in the boot entry config file because the zipl bootloader does not support environment variables. Thus kernelopts cannot be used.

Additional resources

  • For more information about what kernel command line parameters you can modify, install the man-pages package and see kernel-command-line(7), bootparam(7) and dracut.cmdline(7) manual pages.

77.3. What is grubby

grubby is a utility for manipulating bootloader-specific configuration files.

You can use grubby also for changing the default boot entry, and for adding/removing arguments from a GRUB2 menu entry.

For more details see the grubby(8) manual page.

77.4. Setting kernel command line parameters

This section explains how to change kernel command line parameters on the AMD64 and Intel 64 architectures, the 64-bit ARM architectures, and the little-endian variant of IBM Power Systems.

77.4.1. Changing kernel command line parameters for all boot entries

This procedure describes how to change kernel command line parameters for all boot entries on your system.

Prerequisites
Procedure
  1. To add a new parameter, use the grub2-editenv command as in the following example:

    # grub2-editenv - set "$(grub2-editenv - list | grep kernelopts) <NEW_PARAMETER>"

    This command appends an extra argument to the entire parameter list in the global variable kernelopts. As a result, the kernel command line parameter NEW_PARAMETER is set for all boot entries on your system.

  2. To remove a parameter, use the following command:

    # grub2-editenv - set "$(grub2-editenv - list | grep kernelopts | sed -e 's/<PARAMETER_TO_REMOVE>//')"
  3. Reboot your system for the changes to take effect.

As a result, the boot loader is reconfigured, and the kernel command line parameters that you specified are applied.

Note

The alternative way to update the kernel command line parameters is to edit the GRUB_CMDLINE_LINUX parameter in the /etc/default/grub file and execute the # grub2-mkconfig -o /boot/grub2/grub.cfg command to update the GRUB2 configuration file.

Additional resources
  • For more information on how to modify the kernel parameters using the GRUB2 configuration file, see Editing a Menu Entry.

77.4.2. Changing kernel command line parameters for a single boot entry

This procedure describes how to change kernel command line parameters for a single boot entry on your system.

Prerequisites
Procedure
  • To add a parameter execute the following:

    # grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="<NEW_PARAMETER>"
  • To remove a parameter use the following:

    # grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="<PARAMETER_TO_REMOVE>"
Note

By default, there is the options parameter for each kernel boot entry, which is set to the kernelopts variable. This variable is defined in the /boot/grub2/grubenv configuration file.

Important

When you modify a specific boot entry, the contents of the edited kernelopts are stored in the relevant kernel boot entry in /boot/loader/entries/<RELEVANT_KERNEL_BOOT_ENTRY.conf> and have their own command line now. As a result, any additional changes to kernelopts have no affect on that specific kernel boot entry.

Additional resources
  • For further examples on how to use grubby see grubby tool.