Questo contenuto non è disponibile nella lingua selezionata.
Chapter 39. 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.
39.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 kernelopts variable of the /boot/grub2/grubenv file for each kernel boot entry.
				
						For IBM Z, the kernel command-line parameters are stored in the boot entry configuration file because the zipl boot loader does not support environment variables. Thus, the kernelopts environment variable cannot be used.
					
					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.
39.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:
				
6f9cc9cb7d7845d49698c9537337cedc-4.18.0-5.el8.x86_64.conf
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 contains information about the kernel version, the initial ramdisk image, and the kernelopts environment variable that contains the kernel command-line parameters. The configuration file can have the following contents:
				
					The kernelopts environment variable is defined in the /boot/grub2/grubenv file.
				
39.3. Changing kernel command-line parameters for all boot entries
Change kernel command-line parameters for all boot entries on your system.
Prerequisites
- 
							grubbyutility is installed on your system.
- 
							ziplutility 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! - Toggle word wrap Toggle overflow - For systems that use the GRUB boot loader, the command updates the - /boot/grub2/grubenvfile by adding a new kernel parameter to the- kerneloptsvariable in that file.- On IBM Z, update the boot menu: - zipl - # zipl- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 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! - Toggle word wrap Toggle overflow - On IBM Z, update the boot menu: - zipl - # zipl- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
Newly installed kernels inherit the kernel command-line parameters from your previously configured kernels.
39.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
- 
							grubbyandziplutilities 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! - Toggle word wrap Toggle overflow - On IBM Z, update the boot menu: - zipl - # zipl- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 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! - Toggle word wrap Toggle overflow - On IBM Z, update the boot menu: - zipl - # zipl- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
						On systems that use the grub.cfg file, there is, by default, 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.
					
On GRUB systems:
- 
								If the kernel command-line parameters are modified for all boot entries, the grubbyutility updates thekerneloptsvariable in the/boot/grub2/grubenvfile.
- 
								If kernel command-line parameters are modified for a single boot entry, the kerneloptsvariable is expanded, the kernel parameters are modified, and the resulting value is stored in the respective boot entry’s/boot/loader/entries/<RELEVANT_KERNEL_BOOT_ENTRY.conf>file.
On zIPL systems:
- 
								grubbymodifies and stores the kernel command-line parameters of an individual kernel boot entry in the/boot/loader/entries/<ENTRY>.conffile.
39.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 persistently make the changes.
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. The kernel command line starts with linuxon 64-Bit IBM Power Series and x86-64 BIOS-based systems, orlinuxefion UEFI systems.
- Move the cursor to the end of the line. Note- Press 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 - emergencyparameter at the end of the- linuxline:- linux ($root)/vmlinuz-4.18.0-348.12.2.el8_5.x86_64 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 emergency - linux ($root)/vmlinuz-4.18.0-348.12.2.el8_5.x86_64 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 emergency- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - To enable the system messages, remove the - rhgband- quietparameters.
- 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.
39.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.
Procedure
- Add the following two lines to the - /etc/default/grubfile:- 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! - Toggle word wrap Toggle overflow - The first line disables the graphical terminal. The - GRUB_TERMINALkey overrides values of- GRUB_TERMINAL_INPUTand- GRUB_TERMINAL_OUTPUTkeys.- The second line adjusts the baud rate ( - --speed), parity and other values to fit your environment and hardware. Note that a much higher baud rate, for example 115200, is preferable for tasks such as following log files.
- Update the GRUB configuration file. - On BIOS-based machines: - grub2-mkconfig -o /boot/grub2/grub.cfg - # grub2-mkconfig -o /boot/grub2/grub.cfg- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- On UEFI-based machines: - grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg - # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- Reboot the system for the changes to take effect.