Linux Kernel module
| Guide |
The Linux kernel adopts the modular technology. This design minimizes the system kernel and ensures the scalability and maintainability of the kernel. the modular design allows us to load modules to the kernel as needed, realize Dynamic kernel adjustment. The following describes how to operate the kernel. |
Kernel module storage location
The Linux kernel module File is usually named as <Module name. ko>. kernel modules of Centos 6.3 are stored in the/lib/modules/'uname-R'/directory.
View loaded system modules
The lsmod command is used to display the status of the current Linux kernel module. If no parameters are used, all the currently loaded kernel modules are displayed. The output information is the module name, memory usage, and whether the module is in use. If the third column is 0, the module can be detached at any time. If the value is not 0, modprobe cannot be deleted.
[root@centos6 ~]# lsmodModule Size Used bybridge 79950 0stp 2173 1 bridgellc 5642 2 bridge,stpfuse 66891 2autofs4 27212 3sunrpc 263516 1ipt_REJECT 2351 2nf_conntrack_ipv4 9606 1nf_defrag_ipv4 1483 1 nf_conntrack_ipv4iptable_filter 2793 1ip_tables 17831 1 iptable_filter
Load and uninstall the system kernel
The modprobe command can dynamically load and uninstall the kernel module. The specific command is as follows:
[Root @ centos6 ~] # Modprobe ip_vs # dynamically load the ip_vs module [root @ centos6 ~] # Lsmod | grep ip_vs # Check whether the module is successfully loaded [root @ centos6 ~] # Modprobe-r ip_vs # dynamically uninstall the ip_vs Module
The modinfo command can also view the kernel module information:
[root@centos6 ~]# modinfo ip_vs
Modify Kernel Parameters
Temporarily adjust Kernel Parameters
Linux system parameters will be written into the system memory as the system starts up. We can directly modify a large number of files in the/proc directory to adjust the kernel parameters, and this adjustment takes effect immediately, the following example shows how to enable the kernel route forwarding function (set the switch through 0 or 1 ):
[root@centos6 ~]# echo "1" > /proc/sys/net/ipv4/ip_forward
Enable the function of disabling other hosts from pinging the Host:
[root@centos6 ~]# echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
Adjust the total number of files that can be opened by all processes:
[root@centos6 ~]# echo "108248" >/proc/sys/fs/file-max
Permanently adjust Kernel Parameters
You can directly modify the files related to/proc by using the preceding method. The files are no longer valid after the system is restarted. If you want to set the parameters to take effect permanently, you can modify/etc/sysctl. conf file. You can use Vim to modify the file:
[root@centos6 ~]# vim /etc/sysctl.confnet.ipv4.ip_forward = 1net.ipv4.icmp_echo_ignore_all = 1fs.file-max = 108248
Note: parameters modified through the sysctl. conf file do not take effect immediately. You need to use the sysctl-p command to set the parameters to take effect immediately.