• 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 add a kernel parameter only to a specific kernel

by admin

When we add a parameter to /etc/sysconfig/grub and run grub2-mkconfig -o /boot/grub2/grub.cfg, the parameter will be added to all of the kernel entries. This is the default behaviour of a RHEL 7 system. How can we add kernel parameter to a specific kernel version when there are more than one kernel in the system in RHEL7 / CentOS 7.

How to modify a specific kernel only

1. Copy the desired menuentry from /boot/grub2/grub.cfg to /etc/grub.d/40_custom. The entry begins with the line starting with “menuentry” and ends with a line containing “}“.
For example,

# cat /etc/grub.d/40_custom
menuentry 'Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.el7.x86_64-advanced-99fe481b-4138-47bd-bcb2-116f3d76b622' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  1a678f4f-85e4-43c6-b4b3-af1a732510ac
	else
	  search --no-floppy --fs-uuid --set=root 1a678f4f-85e4-43c6-b4b3-af1a732510ac
	fi
	linux16 /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/vg_os-lv_root ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet LANG=en_US.UTF-8
	initrd16 /initramfs-3.10.0-229.el7.x86_64.img
}

2. Change the title after menuentry:

menuentry 'Red Hat Enterprise Linux Server 7.1 (Maipo), with Linux 3.10.0-229.el7.x86_64'

Change to,

menuentry 'RHEL 7.1 with custom parameters'

3. Add parameters to the end of the line starting with linux16.

linux16 /vmlinuz-3.10.0-229.el7.x86_64 root=/dev/mapper/vg_os-lv_root ro nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet LANG=en_US.UTF-8 [additional parameters here]

4. Update /boot/grub2/grub.cfg to apply the changed config file:

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

5. Reboot the system to verify the new kernel parameters.

# shutdown -r now

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. “xfs_log_force: error 5 returned” – XFS Error (CentOS/RHEL 7)
  2. CentOS / RHEL 7 : systemd-analyze command to find booting time delays
  3. CentOS / RHEL 7 : How to set date, time / NTP and timezone using timedatectl
  4. Anonymous User Fails to Upload File to VSFTP Server
  5. How to Log dropped packets using firewalld in CentOS/RHEL 7
  6. How to Add a 3rd Disk to Create a 3-way Mirror RAID1 MD Device (CentOS/RHEL 7)
  7. How To Configure sssd To Work With Multiple Active Directory Domains in Different Forests (CentOS/RHEL)
  8. Yum Command Fails with “Another app is currently holding the yum lock” in CentOS/ RHEL 7
  9. Understanding the dm-multipath Configuration file /etc/multipath.conf
  10. How to add a Custom Script to systemd in CentOS/RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright