Linux kernel boot options (parameters)

Source: Internet
Author: User

In Linux, there are three ways to pass parameters to kernel to control their behavior:

Each configuration option at the time of the 1.build kernel.

2. When the kernel is started, parameters can be passed to kernel when the kernel is called by grub or Lilo and other startup programs.

3. Modify the files in the/proc or/sys directory while the kernel is running.

Here I'm simply talking about the second way, kernel the startup parameters configured in grub.

First, what are the parameters of kernel? In the Linux source code, there is a document like this:

Https://www.kernel.org/doc/Documentation/kernel-parameters.txt

It introduces the various parameters of kernel and their meanings.

Second, thekernel startup parameters are separated by spaces and are strictly case-sensitive (for example, mem and mem are not the same).

Again, for the module-specific kernel parameter notation ,[module name].[ PARAMETER=XX], for example, igb.max_vfs=7 the effect of this kernel startup parameter is equivalent to dynamically loading Module:modprobe IGB max_vfs=7

Also,How does kernel handle these startup parameters? the startup parameters are usually in this form: name[=value_1][,value_2] ... [, Value_10]

"Name" is a keyword that the kernel uses to identify who should be passed the value after "keyword", that is, how to handle the value, whether it is passed to the processing process or as an environment variable or thrown to "init". The number of values is limited to 10, and you can use more than 10 parameters by using the keyword again. First, the kernel check that the keyword is not ' root= ', ' nfsroot= ', ' nfsaddrs= ', ' ro ', ' rw ', ' Debug ' or ' init ', and then the kernel searches the bootsetups array for the registered processing function associated with the keyword. , if a related registered handler function is found, call these functions and pass the values following the keywords as parameters to those functions. For example, you set the parameter name=a,b,c,d at startup, the kernel searches for the bootsetups array, and if "name" is found to be registered, call the Set function of "name" such as Name_setup () and pass a,b,c,d to Name_setup () execution. All types, such as "name=value" parameters, if not received by the Setup function described above, will be interpreted as system-initiated environment variables, such as "term=vt100" startup parameters will be used as a startup environment variable. All parameters that are not received by the kernel Setup function and are not set to an environment variable are left to the INIT process, such as "single".

Here's a brief summary of some of the kernel startup parameters I used to work with.

Root disk related startup parameters:

Root #指出启动的根文件系统 such as: root=/dev/sda1

Ro #指定根设备在启动过程中为read-only, this is usually the case with the default

RW #和ro类似, it is prescribed for read-write, writable

Rootfstype #根文件系统类型, such as: ROOTFSTYPE=EXT4

Console and kernel log related startup parameters:

Console #console的设备和选项, such as: Console=tty0 CONSOLE=TTYS0

Debug #enable kernel Debugging All debug information will be printed on the console

Quiet #disable All log messages to set kernel log level to kern_warning, only very serious information on startup

LogLevel #设置默认的console日志级别, such as: loglevel=7 (0~7 numbers are: Kern_emerg,.., kern_debug)

Time #设置在每条kernel log information and a timestamp before

Memory-related startup parameters:

Mem #指定kernel使用的内存量, MEM=N[KMG]

Maximum number of hugepages #设置大页表页 (4MB size), hugepages=n

CPU-related startup parameters:

MCE # Enable The Machine Check Exception feature.

NOSMP #Run as a single-processor machine. Do not use SMP (multiprocessor)

Max_cpus #max_cpus =n, the maximum number of CPUs the SMP system can use (even if there are more than n CPUs in the system)

RAMDisk related start-up parameters:

INITRD #指定初始化ramdisk的位置, initrd=filename

NOINITRD #不使用initrd的配置 Even if the INITRD parameter is configured

Initialize the relevant startup parameters:

Init #在启动时去执行的程序, init=filename, default value is/sbin/init

PCI-related startup parameters:

PCI #pci相关的选项, I often use pci=assign_buses, also used Pci=nomsi

SELinux Related startup parameters:

Enforcing #SELinux The enforcing status switch, enforcing=0 means simply logging the hazard instead of blocking access, enforcing=1 fully enable, the default value is 0

SELinux #在启动时关闭或开启SELinux, selinux=0 indicates off, selinux=1 indicates SELinux

In addition, the max_loop is used to specify the maximum number of loop devices that can be used.

In the Redhat system, there is also a frequently seen kernel boot parameters--RHGB,RHGB represents Redhat graphics boot, is to see the picture instead of the text information displayed during the startup process, which can be seen after the launch with DMESG
RHGB = redhat graphical boot -This is a GUI mode booting screens with most of the information hidden while the US Er sees a rotating activity icon spining and brief information as to what the computer is doing.

Quiet = Hides the majority of boot messages before RHGB starts. These is supposed to make the common user more comfortable. They get alarmed about seeing the kernel and initializing messages, so they hide them for their comfort.

Resources:

Linux kernel Documents

"Linux Kernel in a nutshell"

Linux kernel boot options (parameters)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.