Kernel module related commands: Lsmod,depmod,modprob

Source: Internet
Author: User
Tags syslog

Lsmod
Features: Lists the state of the kernel loaded modules
Usage: lsmod
Describe:
Lsmod lists the contents of/proc/modules in an aesthetically pleasing manner.
The output is:
Module (module name) size Used by (...) Use

eg. Ne2k_pci 8928 0
8390 9472 1 Ne2k_pci

In/proc/modules, the corresponding:
(module name, module size, ...) Use, module address (guessed, later confirmed))
Ne2k_pci 8928 0-live 0x3086400
8390 9472 1 Ne2k_pci, Live 0xe086000

Depmod
Function: Analyze dependencies of loadable modules, generate MODULES.DEP files and mapping files.
Usage: depmod [-B basedir] [E] [f system.map] [-n] [-v] [version] [-A]
Depmod [-E] [f system.map] [-n] [-v] [version] [filename ...]
Describe:
Linux kernel modules can provide services to other modules (using Export_symbol in code), a service called "symbols". If the second module uses this symbol, the module is obviously dependent on the first module. These dependencies are very complex.

Depmod reads all modules in the/lib/modules/version directory and examines the symbol and required symbol for each module, and then creates a list of dependencies. By default, the list is written to the Modules.dep file in the/lib/moudules/version directory. If the filename in the command is specified, only those specified modules are checked (not very useful).

If the version parameter is provided in the command, the directory generation dependency specified by version is used instead of the version of the current kernel (uname-r).

Options:
-B basedir--basedir Basedir If your module is not properly under/lib/mdules/version, you can specify directory generation dependencies.
The-e--errsyms and-f option are used together to report when a module requires symbol that is not available in other modules. Normally, symbol that is not provided by the module is provided in the kernel.
-F--filesyms System.map provides a system.map file (generated at kernel compile time) with the-e option to report unresolved symbol.
-N--dry_run outputs the results MODULES.DEP and various mapping files to standard output (stdout) rather than to the module directory.
-A--quick check if there is a module that is newer than the module in MODUES.DEP, and if not, quit without rebuilding the file.


Modprobe
Function: Linux kernel add Delete module
Usage:
modprobe [-v] [-v] [-c Config-file] [-n] [-i] [Q] [-O modulename] [modulename] [module parameters ...]
modprobe [-R] [-v] [-n] [-i] [modulename ...]
modprobe [-L] [-t dirname] [wildcard]
modprobe [-c]
Describe:
Modprobe can intelligently add and remove Linux kernel modules (for simplicity, the ' _ ' and '-' is the same in the module name). Modprobe will look at all the modules and files in the module directory/lib/modules/' Uname-r ', in addition to the optional/etc/modprobe.conf configuration file and the/ETC/MODPROBE.D directory.

Modprobe needs an up-to-date MODULES.DEP file that can be generated using DEPMOD. The file lists the other modules needed for each module, modprobe use this to automatically add or remove dependencies on the module.

Options:
-V--verbose Displays what the program is doing, usually modprobe the information in case of a problem.
-C--config overload (^_^, meaning take the overload of C + +) default profile (/etc/modprobe.conf or/ETC/MODPROBE.D).
-C--showconfig Output configuration file and exit
-N--dry-run can be used with the-v option, and debugging is useful
-I--ignore-install--ignore-remove this option causes Modprobe to ignore the install and remove commands that are entered on the command line in the configuration file.
-Q--quiet General modprobe when you delete or insert a module, you will be prompted for an error if you do not find it. With this option, the specified module is ignored and no error messages are prompted.
-R--remove This option causes Modprobe to delete instead of inserting a module. There is usually no reason to delete kernel modules, unless there are some bugs in the module. Your kernel does not necessarily support the uninstall of the module.
-V--verssion Version information
-F--force and simultaneous use of--force-vermagic,--force-modversion same. Using this option is more dangerous.
-L--list List all modules
-A--all inserts all the modules in the command line
-T--type Force-L display module in DirName
-S--syslog error message written to Syslog

Modinfo
Functions: Displaying information for kernel modules
Usage:
Modinfo [-0] [f field] [ModuleName | filename ...]
Modinfo-v
Modinfo-h
Describe:
Modinfo lists information about the modules specified by the command line in the Linux kernel. If the module name is not a filename, it will be searched in the/lib/modules/version directory, just like modprobe.

Modinfo by default, for readability, each of the module's properties is listed in the following format: Fieldname:value.

Options:
-V--version version
-F--field Displays field values only on a single line, which is useful for scripting. The commonly used field are: Author, description, licence, param, depends, alias, filename.
-0--null use '/0 ' characters to separate field values from a new row. More useful for scripts.
-a-d-l-p-N These are the short forms of author, description, license, param, filename.


Insmod
Function: Insert a module into the Linux kernel
Usage: insmod [filename] [modue options ...]
Describe:
Insmod is a small program that inserts a module into the kernel: if the filename is a hyphen '-', the module inputs from the standard input. Most users use modprobe because it is more intelligent.

Rmmod
Function: Remove a module from the kernel
Usage: Rmmod [-F] [-W] [-S] [-v] [ModuleName]
Describe:
Rmmod is a small program that can remove modules from the kernel, and most users use Modprobe-r to remove modules.

Options:
-V--verbose Displays what the program is doing, typically displaying only error messages at execution time.
-F--force This option is very dangerous: unless the kernel is compiled, config_module_force_unload is set to effect, otherwise no effect. Use this option to delete the module that is being used, either as a module that cannot be deleted, or as a module labeled unsafe.
-W--wait Typically, Rmmod refuses to delete the module that is being used. With this option, the specified module is isolated until it is not used.
-S--syslog writes the error message to the syslog instead of the standard error (STDERR).
-V--version Version information

The above content is the reference man translates, if has the question, please use man ... To view the original document, the translation may be incorrect.

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/nihaozjl/archive/2009/02/17/3901174.aspx

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.