1.查看内核版本:uname -r;
Modules are strored in a directory of a hierarchy headed by /lib/modules/kernel-version. which kernel-version is the string report by uname -r.
the typical module subdirectories are:
block modules for a few block-specific devices such as RAID controllers or IDE tape drives
cdrom Devices driver modules for nonstandard CD-ROM devices.
fs Contains drives for filesystems such as MS-DOS(the msdos.o module)
ipv4 Include modular kernel features having to do with IP processing, such as IP masquerading.
misc Anything that doesn't fit into one of the other subdirectories ends up here, note that no mudules are stored at the top of this tree.
net Network interface driver modules/
scsi contains driver modules for the scsi controller
video Contains driver modules for video adapters
module directories are also referred to as tags in the context of module manipulation commands
Manipulating Modules
lsmod
1. syntax lsmod
for each kernel module loaded. display its name, size, use count, and a list of other refering modules. This command yields the same information as is availbale in /proc/modules
example:
here, lsmod shows that quite a few kernel modules are loaded, including file-system(vfat, fat), network, and sound modules, among others:
lsmod
2.insmod
insmod [options] module
Insert a module into the running kernel. The module is located automatically and inserted. You must be logged in as the superuser to insert modules.
-s display results on syslog instead of the terminal.
-v set verbose mode.
example:
insmod msdos
3.rmmod
syntax
rmmod [options] modules
Unless a module is in use or referred to by another module, the rmmod command is used to remove modules from the running kernel. You must be logged in as the superuser to remover modules
-a Remove all unused modules
-s display results on syslog instead of the terminal.
example: rmmod fat
4.modinfo
syntax
modinfo [options] module_object_file
display information about a module from its module_object_file. Some modules contain no information at all, some have a short one-line description. and others have a fairly descriptive message.
-a Display the module's author
-d Display the module's description. -p Display the typed parameters that a module may support. example: modinfo -d /lib/modules/2.2.15-15smp/misc/ftape.o 5.modprobe syntax modprobe [options] module [symbol=value ...] Like inmod, modprobe is used to insert modules. However,modeprobe has the ability to load single modules, modules and their prerequisites, or all modules stored in a specific directory. The modprobe command can also remove modules when combined with -r option. modprobe command determines prerequisite relationships between modules by reading modules.dep at the top of the module directory hierarchy. -a load all modules. -c Display a complete module configuration, include defaults andd directives found in /etc/modules.conf(or /etc/conf.modules, depend on you distribution). The -c option is not used with any other options -l List modules. When used with the -t tag, list only modules in directory tag. For example, if tag is net, then modules in /lib/modules/kernel-version/net are displayed. -r Remove module, simiar to rmmod. Multiple modules may be specified. -s Display results on syslog instead of the terminal/ -t tag Attempt to load multiple modules found in the directory tag until a module succeeds or all modules in tag are exhausted. This action "probes" hardware by successive-insertion attempts for a single type of hardware, such as a network adapter. -v set verbose mode. example: install the msdos filesystem module into the running kernel: modprobe msdos remove fat and msdos modules from the running kernel, assuming msdos is not in use: modprobe -r fat msdos Attempt to load all available network modules: modprobe -t net Configuring Modules configuration file /etc/conf.modules(or in /etc/modules.conf, depending on your distribution), which controls the behavior of modprobe. The /etc/modules.modules file can contain the following information: comments Blank line and lines begin with # are ignored. keep The keep parameter, when found before any path directives, causes the default paths to be retained and added to any paths specified. defile=full_path This directive override the default location for the modules dependency file, modules.dep. for example: defile=/lib/modules/2.2.14/modules.dep options module opt1=val1 opt2=val2..... options for modules can be specified using the options configuration line in conf.modules or on the modprobe command line. The command line over-rides configurations in the file. module is the same of a single module without the .so extension. Options are specified as name=value pairs, where the name is understood by the module and reported using modinfo -p. For example: option opl3 io=0x388 alias Alases can be sued to associate a generic name with a specific module. For example: alias eth0 3c59x pre-install module command This directive causes some shell command to be executed prior to insertion of module. For example, PCMCIA services need to be started prior to installing the pcmcia_core module: pre-install pcmcia_core /etc/rc.d/init.d/pcmcia start install module command This directive allows a specific shell command to override the default module-insertion command. post-install module This directive causes some shell command to be executed after insertion of module. pre-remove module This directive causes some shell command to be executed prior to removal of module. remove module This directive allows a specific shell command to override the default module-removal command post-remove module This directive cause some shell command to be executed after removal of module
|