Introduction to Linux kernel-related folders/proc and/sys

Source: Internet
Author: User

Recently, my article has been very popular. I just want to summarize my knowledge from Marco Polo and send it to my blog. But I didn't expect that an article was first published nine times in the morning... If you really think my article is bad, please tell me the reason. Thank you very much.

This week, Marco talked about Linux kernel compilation and Linux kernel modules, which are easy to understand. So I will share my learning achievements with you. First of all, this is just a simple compilation and manual addition of modules. This article mainly introduces the Linux kernel classification, two folders related to Linux kernel/proc/sys are the theoretical basis for Kernel compilation and addition of kernel modules.

Kernel classification:

1. micro-kernel: To ensure kernel streamlining as much as possible, all devices need to install drivers (do not know if this is correct) such as windows, all the drive areas of your devices were installed later.

2. Single Kernel: the device is directly integrated into the kernel.

Linux is a single kernel, but because of its clever design (you can think like this, there are many "holes" in the kernel appearance for connecting modules), it can make many devices into modules, it is automatically added to the kernel when necessary. Because it is work in the kernel, the efficiency is very high.

Theoretically speaking, the micro-kernel is a more advanced design, but so far, its advantages have not been brought into play. Due to the single-core design of Linux, it is difficult to install the driver, difficult to develop.

Linux Kernel Classification

1. kernel itself

Do you still remember initrd? It is actually generated. It is automatically generated from the script/sbin/mkinitrd after you install the operating system for auxiliary kernel.

2. Kernel Object (kernel module)

They are files ending with. KO. All and Ko files can only be loaded in the kernel. They are located in the/lib/modules Directory, which is about 50 MB in size. The kernel makes the file system and various peripheral drivers into modules, in addition, Each kernel of different versions corresponds to a folder with the same name as the kernel version to store the corresponding kernel module File ### must be strictly matched; otherwise, an error will occur.

Different options and functions are selected during kernel compilation.

RedHat provides three 32-Bit Core versions and two 64-Bit Core versions.
32-bit
Kernel supports up to 32-bit CPU and up to 4 GB memory
Kernel: at 1g startup, the kernel occupies 1 GB of memory, leaving only 3 GB of memory for the process.
Process: 3G
Kernel-PAE supports a maximum of 32 Symmetric Multi-processors and 16 GB memory.
A single process can only have a maximum of 3 GB memory.
Kernel-xen supports xen-based semi-virtualization. Currently, it is not supported and switched to KVM.

64-bit:
Kernel: 64 CPU, 512 GB
Kernel-xen: 126 CPUs, GB memory
The current technology can support 1 TB of memory

Kernel parameters:

The kernel can accept many parameters. For example, grub. conf is passed to the kernel startup level at startup. During system operation, kernel parameters can also be passed. The kernel works in the kernel space, but the user program works in the user space. Therefore, some parameters need to be passed to the kernel through the user space, let the kernel work as needed.

Then pass the parameters to the kernel, which is the role of these two folders today.

Their role:

/PORC is running kernel information ing
Main output: Process Information
Memory Resource Information
Disk partition information, etc.
/Sys
Driver information of hardware devices


These are all pseudo file systems. If you understand the parameters of these files and pass special values to them, you can adjust the Kernel Operating features and hardware operating features in real time.

Then we open the/proc directory to view the content. I will not write the specific commands. Here I will only introduce the functions of the directories I learned based on the directory tree (through color recognition ), if you are interested, refer ~

/Proc/
1. What are the command line commands and their parameters for starting a process using cmdline?
1/proc/cmdline gurb parameter file passed to the kernel. Later, you can read its parameters through the script to determine what information is transmitted to the kernel at startup.
1/maps memory usage information ing
1/MEM memory information
1/IO read/write
1/STAT Process Information
1/status

ACPI senior team member management subsystem Information
Asoud sound information
Budyinfo refers to the partner system information, which is used to reclaim memory and prevent memory fragments.
Bus system hardware bus information
Cpuinfo
Crypto Encryption
All character devices and Block devices on the current system
Diskstat disk status information (hard to understand)
Iostat can view its information through this file
Direct Memory Access through DMA, which enables direct ing between memory and the corresponding disk device. When access disconnects data from CPU management, it can still be read from the disk to the memory.
System Optimization Device
FB (frame buffer) frame caching provides drivers for some special video card display devices.
All file systems enabled in the current system
/Cpuset CPU group, you can bind the process to the CPU, you can mount it to view the bundle information, it is also a pseudo directory
IDE
FS
Interruptes interrupt (hardware terminal, Soft Interrupt)
Ioports hardware I/O port information
Average loadavg load. Run the uptime command to view the file.
Locks file lock. The file process does not allow two processes to write files simultaneously.
Molues module in the current system
Mdstat raid
Meminfo memory information
Partition information recognized by the partitions Kernel
Schedstat process scheduling information
Slabinfo memory subsystem information is the same as budyinfo
SWAps swap partition information
File displayed by the uptime command
Version 'uname-R'
Vmstat
The partition information of zoneinfo memory. It is the BIOS segment of the normal DMA segment.

/Proc/sys any information output in the SYS directory can be managed by adjusting their parameters
Crypto
Debug
Dev
Ls
FS
Kernel
Net

/IPv4 contains adjustable network modules
/Change icmp_echo_ignore_all to 1, and Ping is different.

Ip_forward is used to define if there are two NICs on the host, or if one Nic has two addresses and is in different network segments,
It can enable packet routing (direct connection Routing) forwarding between two networks. It can determine your
Whether the host can be used as a router or gateway. The default value is 0.

Max_orphans maximum number of orphan links
Tcp_fin_timeout tcp fin packet wait timeout
Tcp_max_syn_backets network optimization is actually to tune these parameters
Tcp_mem buffer size

Tcp_rmen read buffer size
TCP _ wmen write buffer size
Whether the number of tcp_reuse TCP links can be reused and reused multiple times
SunRPC
VM

/Dorp_caches is used to release the cache in the memory

Differentiate which files can pass parameters: All files with W permissions can pass parameters.

How to adjust the value of the kernel parameter file is generally in/proc/sys
1. Temporary transfer (temporarily valid, effective immediately ):

# Echo> Echo 1>/proc/sys/NET/IPv4/ip_forward # Full path # sysctl-W net. ipv4.ip _ forward = 1 # Remove/proc/sys. separate


2. Valid permanently (but not immediately)
By setting/etc/sysct1.conf, It is the Kernel Parameter read by RC. sysinit at startup.

For example

Net. ipv4.ip _ forward = 1 # enable route forwarding

In addition, if you want to make the modified value take effect immediately

#sysctl -p          

Displays the values of all currently running effective Kernel Parameters

#sysctl -a          

####### This file is an intuitive and important file for the system engineer's career

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.