Thursday, March 31, 2022

[SOLVED] What is the correct method to modify kernel boot option in grub2.cfg?

Issue

The kernel shipped with RHEL 7 is 3.10, then I build and install 4.2.0 successfully. But I find in /etc/grub2.cfg, the kernel boot option lacks my want:intel_iommu, so I add "intel_iommu=on" in /etc/grub2.cfg manually:

menuentry ...{
        ......
        linux16 /vmlinuz-4.2.0-rc8+ root=/dev/mapper/rhel-root ro rd.lvm.lv=rhel/root crashkernel=auto  rd.lvm.lv=rhel/swap vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet LANG=en_US.UTF-8 intel_iommu=on
        ......
}

Then reboot the kernel, from dmesg output:

[root@localhost /]# dmesg | grep DMAR
[    0.000000] DMAR: IOMMU enabled

I can see the "intel_iommu=on" takes effect.

I am just wonder what is the correct way to modify kernel boot option in grub2.cfg. Does adding option need to modify grub2.cfg manually?


Solution

After investigating, I find the answer:

(1) According to your need, modify files in /etc/grub.d directory or /etc/default/grub file;
(2) Use grub2-mkconfig -o /boot/grub2/grub.cfg command to generate new configure file.

For example, adding "intel_iommu=on":
(1) Add "intel_iommu=on" in /etc/default/grub file;
(2) Execute grub2-mkconfig -o /boot/grub2/grub.cfg.

Then it take effects!



Answered By - Nan Xiao
Answer Checked By - David Marino (WPSolving Volunteer)