分享

How to add kernel boot parameters via GRUB on Linux

 浸心阁 2015-06-30

The Linux kernel can be supplied with various parameters during boot time or at run time. These parameters customize the default behavior of the kernel, or inform the kernel about hardware configuration. Kernel parameters can be changed at run time by modifying files in /proc or /sys, while certain kernel parameters need be passed to the kernel at boot time by a boot loader such as GRUB or LILO.

In this tutorial, I will describe how to add kernel boot parameters via GRUB on Linux.

If you want to change or add kernel parameters when you are using GRUB boot loader, you can edit GRUB config file. The following are distro-specific ways to add kernel boot parameters to a GRUB config file.

Add Kernel Boot Parameters on Debian or Ubuntu

If you want to add kernel parameters during boot time on a Debian based system, edit GRUB config template at /etc/default/grub. Add a kernel parameter in the form of "name=value" in GRUB_CMDLINE_LINUX_DEFAULT variable.

$ sudo -e /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="...... name=value"

Then run the following command to actually generate a GRUB config file.

$ sudo update-grub

If the command update-grub is not found, you can install it as follows.

$ sudo apt-get install grub2-common

Add Kernel Boot Parameters on Fedora

To add kernel parameters during boot time on Fedora, edit GRUB config template at /etc/default/grub. Add a kernel parameter in the form of "name=value" in GRUB_CMDLINE_LINUX variable.

$ sudo -e /etc/default/grub
GRUB_CMDLINE_LINUX="...... name=value"

Then run the following command to generate a GRUB2 config file.

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Add Kernel Boot Parameters on CentOS

To add kernel parameters during boot on CentOS, directly edit a GRUB config file located at /boot/grub/grub.conf. In the config file, look for the entry describing the default Linux image used. The string "default=N" at the top of the config file indicates which entry is the default image.

Under the default image entry, append a kernel parameter to the line starting with "kernel /vmlinuz-". A kernel parameter should be formatted as "name=value".

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多