How to manage modules in the Linux kernel?

  

The Linux kernel is divided into several modules, which are convenient for management and can easily add new modules to enrich the functions of the Linux system. The following is a description of the kernel module path and view kernel modules, how to manage the Linux system kernel module?

a kernel module named storage location

Linux kernel module files usually, CentOS 6.3 system kernel modules are stored centrally in /lib /modules /`uname -r In the `/[1] directory (the information obtained by uname -r is the version number of the current kernel). The following is a few examples to illustrate the basic operation of the kernel module.

Second, view the loaded kernel module

The lsmod command is used to display the current Linux kernel module status, not using any parameters will display all kernel modules currently loaded. The output three columns of information are the module name, the occupied memory size, and whether it is being used. If the third column is 0, the module can be uninstalled at any time. If it is not 0, the modprobe delete module cannot be executed.

1.[root@centos6 ~]# lsmod

2.Module Size Used by

3.bridge 79950 0

4.stp 2173 1 Bridge

5.llc 5642 2 bridge,stp

6.fuse 66891 2

7.autofs4 27212 3

8.sunrpc 263516 1

9.ipt_REJECT 2351 2

10.nf_conntrack_ipv4 9506 2

11.nf_defrag_ipv4 1483 1 nf_conntrack_ipv4

12.iptable_filter 2793 1

13 .ip_tables 17831 1 iptable_filter

14. (Partial output omitted)

<! --[if ! supportLists]-->2.9.3<! --[endif]-->Loading and Unloading Kernel Modules

Third, the modprobe command can dynamically load and unload kernel modules

1.[root@centos6 ~]# modprobe ip_vs #动态Load ip_vs module

2.[root@centos7 ~]# lsmod | Grep ip_vs #Check if the module is loaded successfully

3.[root@centos7 ~]# modprobe -r ip_vs #dynamic uninstall ip_vs module

The modinfo command can view kernel module information:

1.[root@centos7 ~]# modinfo ip_vs

2.filename: /lib/modules/2.6.32-279.el6.x86_64/kernel/net/netfilter/ipvs/ip_vs.ko< Br>

3.license: GPL

4.srcversion: 01386EABC060B63920E181B

5.depends: ipv6,libcrc32c

6.vermagic: 2.6.32-279. El6.x86_64 SMP mod_unload modversions

Fourth, modify the kernel parameters

The kernel module loaded by the above modprobe mode is only valid at present, the module will not be loaded again after the computer restarts, if you want the system To automatically mount the kernel module at boot, you need to write the modprobe command to the /etc/rc.sysinit file:

1.[root@centos7 ~]# echo “modprobe ip_vs” >> /etc/Rc.sysinit

When the kernel module is no longer needed, you can pass the corresponding mo in the /etc/rc.sysinit file. The dprobe command is deleted, but it needs to be restarted to take effect. At this point, the kernel module can be removed immediately by the modprobe -r command:

1.[root@centos6 ~]# modprobe -r ip_vs

<! --[if ! supportLists]-->2.9.4<! --[endif]-->Modify kernel parameters

<! --[if ! supportLists]-->1.<! --[endif]--> Temporary adjustment of kernel parameters

Linux kernel parameters will be written to memory as the system starts, we can directly modify a large number of files in the /proc directory to adjust kernel parameters. And this adjustment is effective immediately.

The above is the Linux system to manage the kernel module. Using the method described in this article, you can view the kernel module, load and unload the kernel, and modify the kernel parameters. I hope I can help you. .

Copyright © Windows knowledge All Rights Reserved