The post outlines the steps to modify the kernel command line (and, thus, kernel boot parameters) in CentOS/RHEL 7 with GRUB2 installed as a boot loader.

 

Backup the GRUB configuration Files

 

Make copy of the GRUB2 configuration files as a precaution:

 

For an MBR (BIOS-based) system:

 

# cp /etc/default/grub /etc/default/grub-backup

 

# cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg-backup

 

For a GPT (UEFI-based) system:

# cp /etc/default/grub /etc/default/grub-backup
# cp /boot/efi/EFI/redhat/grub.cfg /boot/efi/EFI/redhat/grub.cfg-backup

 

Editing /etc/default/grub file

 

1. Open the /etc/default/grub file for editing:

# vi /etc/default/grub

 

2. This file contains multiple GRUB2 options. Kernel boot parameters are specified by the GRUB_CMDLINE_LINUX option. Below is a sample /etc/default/grub configuration file.

# cat /etc/default/grub 
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200"
GRUB_CMDLINE_LINUX="console=ttyS0,115200 console=tty0 vconsole.font=latarcyrheb-sun16 crashkernel=auto  vconsole.keymap=us"
GRUB_DISABLE_RECOVERY="true"

 

3. Once the file is edited, save it.

 

Generating new grub.cfg file

 

1. Once the file is edited, save it and run the command specified below to generate a new grub.cfg file:

 

For an MBR (BIOS-based) system:

# grub2-mkconfig -o /boot/grub2/grub.cfg

 

For a GPT (UEFI-based) system:

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

 

2. Finally, reboot the system to apply the changes:

# systemctl reboot

 

Verify

 

Once the system is up, you can verify the kernel command line with the below command.

# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-3.10.0-693.21.1.el7.x86_64 root=UUID=0f790447-ebef-4ca0-b229-d0aa1985d57f ro console=ttyS0,115200 console=tty0 vconsole.font=latarcyrheb-sun16 crashkernel=auto vconsole.keymap=us

 

Ця відповідь Вам допомогла? 0 Користувачі, які знайшли це корисним (0 Голосів)