CentOS / RHEL 7 : How to modify the kernel command line

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_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
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"


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




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 Users Found This Useful
Was this answer helpful?

Related Articles

How can I configure a ip range in CentOS7?

You have to use a range file Edit /etc/sysconfig/network-scripts/ifcfg-enp0s3 and make...

Adding a Public IPv6 Address to a Linux Server (CentOS 7)

To configure an additional public IPv6 address in CentOS 7, proceed as follows:...

How To Install EPEL Repository On CentOS And RHEL 7

How to install EPEL for Centos 7 [root@localhost ~]# cat  /etc/centos-release CentOS Linux...

Common Commands (CentOS 7)

Basic Configuration Query or System Locale...

Install LAMP Stack on CentOS 7

Install LAMP Stack on CentOS 7 One of the most simple and barebones solutions you can have for...