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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. How to monitor the status of dm-multipathing and multipath devices (path groups) in Linux
  2. How to enable IPv6 on CentOS / RHEL 7
  3. How to enable bind query logging to find out Who’s Querying a Name Server
  4. How to Create Yum Repository For System Packages Installation in CentOS/RHEL
  5. RHEL 7 – RHCSA Notes – Set enforcing and permissive modes for SELinux
  6. Beginners Guide to Udev in Linux
  7. How to change the number of commands stored in Bash History
  8. Audit Rule Configuration not Reflected – How to troubleshoot
  9. How to send Audit Logs to Remote Rsyslog Server in CentOS/RHEL 6,7
  10. How to Set CPU Affinity for SYSTEMD Process in CentOS/RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary