Linux kernel parameter command line setup

Source: Internet
Author: User

Now CPU2 nuclear more common, usually with Linux on the Internet may not need dual-core or even 4 cores, most of the distribution kernel is enabled Cpu_hotplug, to/SYS/DEVICES/SYSTEM/CPU can see Folders cpu0, CPU1, In addition to CPU0 (this cannot be closed) there is a online file under each folder, write 0 can close the core, such as my T7300,echo ' 0 ' >/sys/devices/system/cpu/cpu1/online can shut down the second core, Does not affect small applications. To turn it on, Echo 1 inside. This operation seems to be root complete, the light has root authority is not enough, you must first Su and not sudo, I am here. Then your hosting support can even tear down the CPU off! Of course, the average desktop user does not dynamically migrate the CPU between several machines to play ...
Adding maxcpus=n to the Boot grub parameter kernel (GRUB1) or Linux (2) will start the first N cores.
This will have several uses: 1, close to 1 or 2 cores, can save electricity. 2. Close all odd cores, equivalent to disabling Hyper-threading

But there are a few problems to solve: 1, shut down the core, power consumption is down, why the computer temperature did not change it? 2, if it is closed and then open the core, Cpufreq will expire,/sys/devices/system/cpu/cpun/cpufreq/this directory will disappear, can only run at the highest frequency, unloading and reloading acpi-cpufreq also no use, Solve how to adjust CPU frequency, thank you!

--------------------------------------------------------------------------------------------------------------- --------------

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 such a document Documentation/kernel-parameters.txt, it introduces the parameters of kernel and its significance.

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, kernel Check the keyword is not ' root= ', ' nfsroot= ', ' nfsaddrs= ', ' ro ', ' rw ', ' Debug ' or ' Init ', then the kernel searches the bootsetups array for the registered handler that is associated with the keyword, and if the relevant registered handler is found, call these functions and pass the values following the keyword 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 user sees a Rotating activity Icon spining and brief information as to what's 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"

--------------------------------------------------------------------------------------------------------------- ----------------

Kernel/vmlinuz-2.6.18-164.el5 ro root=/dev/volgroup00/logvol00 rhgb quiet maxcpus=4 mem=1024m initrd/ Initrd-2.6.18-164.el5.img

After reboot, the number of cores started is 4,mem 1024M.

Linux kernel parameter command line setup

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.