8. Linux kernel and kernel module

Source: Internet
Author: User

since you are dealing with kernel modules, it is natural to understand the dependencies between the modules provided by the kernel. Basically, the kernel module is placed at/lib/modules/$ (uname-r)/kernel, which is divided into several directories:

Arch: Options related to the hardware platform, such as the CPU level.

Crypto: Encryption techniques supported by the kernel, such as MD5 or DES.

Drivers: Some hardware drivers, such as video cards, network cards, PCI-related hardware.

FS: File systems supported by the kernel, such as VFAT, ReiserFS, NFS, and so on.

LIB: some functions.

NET: Various protocol data related to the network, as well as Firewall module (net/ipv4/netfilter/*) and so on.

Sound: Various modules related to audio.

The kernel module extension of the Linux kernel2.6.x version must end with ". Ko" .

Depmod

If we were to examine the main information of these modules one by one and then define their dependencies, it would be unrealistic.

Liunx provides a solution to the dependencies of some modules, that is to check/lib/modules/$ (uname-r)/modules.dep This file, then how to create this file?

#depmod [-ane]

L Parameters

Without any parameters, Depmod will proactively analyze the current kernel module and re-write to/lib/modules/$ (uname-r)/modules.dep.

-A: Finds newer modules than the MODULES.DEP file and updates them if a new module is found.

-N: does not write to the MODULES.DEP file, but outputs the result to the screen.

-E: Displays the name of the module that is currently loaded that is not executable.

View kernel modulesA. Lsmod

#lsmod

Module: module name;

Size: the size of the module;

used by: whether this module is used by other modules;

As shown, Nf_nat_ipv4 will be used by Iptable_nat, simply put, when you want to load the Iptable_nat module, you need to load the Nf_nat_ipv4 module before you can.

B. Modinfo

View module Information

#modinfo [-ADLN] [Module_name|filename]

Parameters:

-A: Lists only the author's name;

-D: Lists only the instructions for the module;

-L: Only the authorization of the module is listed;

-N: Lists only the detailed path of the module;

#modinfo-A e1000e

#modinfo-D e1000e


#modinfo-L e1000e


#modinfo-N e1000e


kernel module loading and deletion

If you want to load the kernel module yourself, the simplest way is to use the Modprobe command, because Modprobe will proactively look for MODULES.DEP content, first overcoming the module dependencies before deciding which modules to load.

The insmod is completely user-loaded with a full file name module and does not actively analyze module dependencies.

A. Insmod

#insmod [/full/path/module_name] [parameters]

For example:

#insmod/lib/modules/$ (uname-r)/kernel/fs/cifs/cifs.ko

#lsmod |grep Cifs.ko

B. Rmmod

#rmmod [-FW] Module_name

Parameters:

-F: Forces the module to be removed, whether or not it is being used

-W: If the module is being used, wait for the module to be used and delete it

#rmmod CIFS

c. modprobe

#modprobe [-LCFR] Module_name

Parameters:

-C: List all current system modules

-L: Lists all modules currently in/lib/modules/$ (UNAME-R)/kernel complete file

-F: Force the module to load

-r: Similar to Rmmod, delete a module

Example:

Loading the CIFS module

#modprobe CIFS

Deleting a CIFS module

#modprobe-R CIFS


8. Linux kernel and kernel module

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.