Linux module management commands

Source: Internet
Author: User
1. lsmod lists the loaded kernel modules. lsmod lists the names and sizes of loaded modules in the system. you can also view/proc/modules, we can also know the modules that the system has loaded. 2. modinfo: View module information. 1. lsmod: list loaded kernel modules.

Lsmod lists the names and sizes of loaded modules in the system. you can also view/proc/modules. we can also know the loaded modules.

2. modinfo View module information

Modinfo can view the module information and determine the purpose of the module by viewing the module information.

3. modprobe mount the new module and the module on which the new module depends

Modprobe our common function is to mount a module. when a kernel module is mounted, the modules on which this module depends are also mounted. of course, modprobe also lists all kernel modules, there is also the function of removing modules. next we will give an example to illustrate our common functions and parameters;

Modprobe [-v] [-V] [-C config-file] [-n] [-I] [-q] [-o] [parameters...] YHJLinux Alliance

Modprobe-r [-n] [-I] [-v]... YHJLinux Alliance

Modprobe-l-t [-a...]

The content in the/etc/modprobe. conf file is as follows:

Alias scsi_hostadapter mptbaseYHJLinux Alliance

Alias scsi_hostadapter1 mptspi

The last column is the module name, with the module alias in the middle. So if we know the name of a module, how do we know its alias? Run the following command:

# Modprobe-c YHJLinux Alliance

You can view the alias YHJLinux for all modules.

YHJLinux Alliance

# Modprobe-c module name | grep module name

Modprobe-l is used to list all modules in the kernel, including mounted and unmounted modules. through modprobe-l, we can view the modules we need and mount them according to our needs; in fact, the list of modules read by modprobe-l is located in the/lib/modules/uname-r directory, where uname-r is the kernel version;

Note: The module name cannot contain a suffix. the modules we see through modprobe-l are all with. ko or. o suffixes;

4. rmmod remove mounted modules

5. depmod: List of module dependencies created

This module management tool is used to create a list of module dependencies. just pay attention to a few parameters. Currently, the Linux release uses the kernel version 2.6x to automatically resolve dependencies, this command is fine. The module also has dependencies before. for example, if we want to drive a USB mobile hard disk, there are currently two types of drivers: udev, which are available in the kernel, however, it is not stable at present. Another method is to use the usb-storage driver, while the usb-storage depends on the scsi module. Therefore, we need to use the usb-storage module, you also need to compile and install scsi;

Another example is the sata hard disk. in Linux, the device represents/dev/sd *, for example,/dev/sda,/dev/sdb... to drive a sata hard disk, you need to select sata in the kernel, compile it into a module, or build it into the kernel. at the same time, you need to select the ide in the kernel, scsi support;

Depmod-program to generate modules. dep and map files. (create dependency for modules. dep file or ing file)

[Root @ localhost beinan] # depmod-a note: for all columns in/etc/modprobe. conf or/etc/modules. create dependencies between all modules in conf and write them to modules. dep file; YHJLinux Alliance

[Root @ localhost beinan] # depmod-e note: lists mounted but unavailable modules. YHJLinux Alliance

[Root @ localhost beinan] # depmod-n note: lists the dependencies of all modules, but only outputs (Write the dependency file on stdout only)

Note: modules. dep is located in the/lib/modules/kernel version directory.

6. insmod mounting module

The insmod tool is a bit similar to modprobe, but it does not have a strong modprobe function. in the Mount module, modprobe does not need to specify the path of the module file or the suffix of the file. o or. ko; what insmod needs is the absolute path of the directory where the module is located, and must contain the module file name suffix (modulefile. o or modulesfile. ko)

7. configuration files related to kernel module loading

Module configuration file modules. conf or modprobe. conf

The automatic mounting module of the kernel module is usually located in a configuration file. the common Linux releases all have/etc/modules. conf or/etc/modprobe. conf. For example, the file automatically loaded by the Fedora Core 4.0 kernel module upon startup is/etc/modprobe. conf; in this file, it is generally written to the module's load command or module alias definition. for example, in modules. A similar line may be released in conf;

Alias eth0 8139too

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.