Linux kernel module Management
Linux Kernel Modular Design1. Linux kernel design: single kernel, modular (dynamic loading and uninstallation)
(1) Linux: Single-core design, but fully draws on the advantages of the micro-kernel system design; introduces a modular Mechanism for the kernel;
(2) kernel components:
Kernel: kernel core, generally in bzImage format, usually located in the/boot directory, named vmlinuz-VERSION-release;
After the system starts, the file will not be used because it has been loaded into the memory and can be conveniently managed under/boot.
Kernel object: kernel module, usually placed in/lib/modules/VERSION-release/
The kernel module and the kernel core version must be strictly matched;
2. kernel module: Compilation and selection mode
[]: N. do not compile this part.
[M]: Module, which is compiled in modular mode and can be loaded temporarily, occupying disk space, without occupying kernel space
[*]: Y, which is compiled into the kernel core and can be called directly.
3. ramdisk: Auxiliary file, which is not required. It depends on whether the kernel can directly drive the device where rootfs is located.
Ramdisk: A simple root file system with the following drivers:
Driver of the target device, such as the driver of the SCSI device;
Driver of a logical device, such as the driver of an LVM device;
File systems, such as xfs file systems;
Kernel module information acquisition and management commands1. ldd: print the library file on which the binary application depends-print shared library dependencies
Format: ldd [OPTION]... FILE...
Display:
1) Name of the dependent library file => path of the dependent library file (corresponding to the memory load symbol link ing)
2) portal to the entire system call library
linux-vdso.so.1 => (0x00007fff293fe000)/lib64/ld-linux-x86-64.so.2 (0x00007f0228073000)
2. uname: Obtain kernel information-print system information
Format: uname [OPTION]…
Uname-a: displays all kernel information.
Uname-v: the version number of the kernel.
Uname-r: release Number of the kernel release
Uname-n: Host Name
3. lsmod: List Kernel Modules
The displayed kernel is from/proc/modules.
Module name, size, number of times referenced, and reference
4. modinfo command: displays the details of the specified module.
Format: modinfo [-F field] [-k kernel] [modulename | filename...]
-K kernel: if multiple kernels coexist, query the module information on the other kernel.
-F field: only information about the specified field is displayed;
-N: displays the file path;
Display the relevant information by reading the original data of 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: Implements module loading and uninstallation, and mounts the dependent modules.
Format: modprobe [-r] module_name
Dynamic module loading: modprobe module_name
Dynamic uninstall: modprobe-r module_name
Note: Do not uninstall the mounted modules by default.
6. depmod:-Generate modules. dep and map files
Tool for generating the dependency file and system information ing file of the kernel module;
7. insmod and rmmod: module loading and uninstallation. The module dependency cannot be automatically solved.
Insmod [filename] [module options...]
Filename: file path of the module File;
Rmmod [module_name]
Ramdisk File Management1. mkinitrd (CentOS 5): re-creates a ramdisk file for the kernel in use.
# Mkinitrd [OPTION...] []
-- With =: in addition to the default module, it must be loaded to the module in initramfs;
-- Preload =: The modules provided by initramfs need to be preloaded;
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 System1./proc: the output interface of Kernel Status and statistics. It also provides a configuration interface,/proc/sys
(1) parameters:
Read-Only: information output; for example,/proc/#/*, process-related information
Writable: users can specify a "new value" to configure a certain function or feature of the kernel./proc/sys/
Format:/proc/sys: net/ipv4/ip_forward is equivalent to net. ipv4.ip _ forward
(2) Modify parameters
1) sysctl command
Used to view or set the parameter values in the/proc/sys directory; sysctl [options] [variable [= value]
View: # sysctl-a; # sysctl variable
Modify the value: # sysctl-w variable = value
2) File System Command (cat, echo)
View: # cat/proc/sys/PATH/TO/SOME_KERNEL_FILE
Set: # echo "VALUE">/proc/sys/PATH/TO/SOME_KERNEL_FILE
3) configuration file:/etc/sysctl. conf,/etc/sysctl. d/*. conf
Effective immediately: 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 Directory: introduced after Kernel 2.6
Sys File System: outputs the property information of each hardware device identified by the kernel, as well as configurable parameters of the kernel for hardware features;
You can modify these parameters to customize the operating characteristics of the hardware device;
Udev: Read the hardware device information in the/sys directory and create device files for each hardware device as needed;
Udev is a user space program; dedicated tools: devadmin, hotplug;
When udev creates a device file for a device, it reads the rule file defined in advance.
Generally, it is under the/etc/udev/rules. d/directory and/usr/lib/udev/rules. d/directory;
Source: http://blog.chinaunix.net/uid-7573623-id-2048961.htmloriginal Author: Xu ding
This article Reprinted from: http://www.linuxprobe.com/fedora-24-alpha-and-gnome32/