• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

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

by admin

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
CentOS / RHEL 7 : GRUB2 configuration file /boot/grub2/grub.cfg explained
CentOS / RHEL 7 : How to Modify GRUB2 Arguments with grubby
CentOS / RHEL 7 : Change default kernel (boot with old kernel)

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Troubleshooting slow network communication or Connection Timeouts in Linux
  2. atop: command not found
  3. getopt Command Examples in Linux
  4. light: command not found
  5. logwatch : command not found
  6. CentOS / RHEL 7 : How to follow the mount order in /etc/fstab
  7. pmap: command not found
  8. How to create a Python Dictionary
  9. “Couldn’t authenticate with keytab while discovering which salt to use: hostname: KDC has no support for encryption type” – error while joining domain
  10. “java” command does not run the JVM that has been installed

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright