Modular design of the Linux kernel
1. Linux kernel design: Single core, modular (dynamic loading and unloading)
(1) Linux: Single-core design, but fully reference the advantages of micro-kernel system design, the introduction of the kernel of the modular mechanism;
(2) components of the kernel:
Kernel: Kernel core, generally bzimage format, usually located in the/boot directory, named Vmlinuz-version-release;
The file is not in use when the system is started, because it has been loaded into memory and is conveniently managed under/boot
Kernel object: Kernel module, typically placed in/lib/modules/version-release/
Kernel module and kernel Core version must be strictly matched;
2. Kernel module: Compile selection mode
[]:n, do not compile this section
[M]:module, modular compilation, can be temporarily mounted, takes up disk space, does not occupy the kernel space
[*]:y, compiled into kernel core, can be called directly
3.ramdisk: Auxiliary file, not required, depends on whether the kernel can directly drive the device on which Rootfs is located
RAMDisk: A lite version of the root file system, which provides the following drivers:
Target device drivers, such as SCSI device drivers;
Logical device drivers, such as those of LVM devices;
File systems, such as XFS file systems;
Kernel module information acquisition and management commands
1.ldd: Print the library file that the binary application relies on-print shared library dependencies
Format: LDD [OPTION] ... FILE ...
Show:
1) Dependent library file name = = Dependent library file path (corresponds to memory load symbolic link map pointing)
2) The entry of the entire system call library
Linux-vdso.so.1 = (0x00007fff293fe000)/lib64/ld-linux-x86-64.so.2 (0x00007f0228073000)
2.uname: Kernel Information Acquisition-print System Information
Format: uname [OPTION] ...
UNAME-A: Show all kernel information
UNAME-V: Compile version number of the kernel
Uname-r: Release number of the kernel
Uname-n: Host Name
3.lsmod: List kernel modules
The kernel shown is from/proc/modules
Module name, size, number of references, what reference
4.modinfo Command: Displays detailed information for the specified module
Format: Modinfo [-f field] [-K kernel] [modulename|filename ...]
-K Kernel: To query the module information on another kernel when multiple cores coexist
-F field: Displays only the information for the specified field;
-N: Show file path;
Display relevant information by reading the original data from the/lib/modules/#######/* file
Display content: File name, protocol, description, author, alias, applicable to Rhel version number, dependent module, signature unit, signature, encryption algorithm
5.modprobe: Implement module loading and unloading while mounting dependent modules
Format: modprobe [-R] Module_name
Dynamic loading of modules: Modprobe module_name
Dynamic Uninstall: Modprobe-r module_name
Note: The default loaded module should not be unloaded arbitrarily
6.depmod:-Generate modules.dep and map files
Kernel module dependency file and System Information mapping file generation tool;
7.insmod, Rmmod: module loading and unloading, can not automatically solve the module dependencies
insmod [filename] [module Options ...]
FileName: The file path of the module file;
Rmmod [Module_name]
management of RAMDisk files
1.MKINITRD (CentOS 5): Re-authoring RAMDisk files for the currently in-use kernel
# MKINITRD [OPTION ...] []
--with=: Modules that need to be loaded into the INITRAMFS in addition to the default modules;
The modules provided by the--PRELOAD=:INITRAMFS require pre-loaded modules;
Example: ~]# mkinitrd/boot/initramfs-$ (UNAME-R). IMG $ (UNAME-R)
2.dracut (CentOS 6/7, compatible with 5):-low-level tool for generating an INITRAMFS image
# Dracut [OPTION ...] [ []]
Example: ~]# dracut/boot/initramfs-$ (UNAME-R). IMG $ (UNAME-R)
kernel information output pseudo file system
1./proc: Output interface for kernel status and statistics, and a configuration interface for/proc/sys
(1) Parameters:
Read-only: information output; for example,/proc/#/*, process-related information
Writable: Can accept the user to specify a "new value" to achieve a kernel function or feature configuration;/proc/sys/
Format:/proc/sys:net/ipv4/ip_forward equivalent to Net.ipv4.ip_forward
(2) Modify the parameter mode
1) sysctl command
Designed to view or set values for parameters under the/proc/sys directory; sysctl [options] [Variable[=value]
View: # sysctl-a;# Sysctl variable
Modify its value: # sysctl-w Variable=value
2) file system commands (CAT, Echo)
View: # Cat/proc/sys/path/to/some_kernel_file
Settings: # echo "VALUE" >/proc/sys/path/to/some_kernel_file
3) configuration file:/etc/sysctl.conf,/etc/sysctl.d/*.conf
Immediate effect way: sysctl-p [/path/to/config_file]
(3) Important kernel parameters
Net.ipv4.ip_forward: Core forwarding;
Vm.drop_caches:
Kernel.hostname: Host name;
Net.ipv4.icmp_echo_ignore_all: Ignore all ping operations;
2./sys Catalog: Introduced after Kernel version 2.6
SYS file system: The output kernel identifies the relevant property information of each hardware device, and also has the configurable parameters of the kernel to the hardware characteristics;
To modify these parameters, you can customize the working characteristics of hardware equipment.
Udev: Create device files for each hardware device by reading the hardware device information in the/sys directory as required;
Udev is a user-space program; special tools: Devadmin, HotPlug;
When Udev creates a device file for a device, it reads its pre-defined rule file
Generally in the/etc/udev/rules.d/directory, as well as the/usr/lib/udev/rules.d/directory;
This article was reproduced from: http://www.linuxprobe.com/linux-kernel-module/
Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/
Linux Kernel module Management related detailed