Difference between revisions of "Kernel modules"

From ArchWiki
Jump to: navigation, search
(Using files in {{Filename|/etc/modprobe.d/}}: removed formatting from section heading)
(group commands for getting info, simplify)
Line 17: Line 17:
  
 
{{Note|Module names often use underscores ("_") or dashes ("-"), however those symbols are interchangeable both when using the {{Codeline|modprobe}} command and in configuration files in {{Filename|/etc/modprobe.d/}}.}}
 
{{Note|Module names often use underscores ("_") or dashes ("-"), however those symbols are interchangeable both when using the {{Codeline|modprobe}} command and in configuration files in {{Filename|/etc/modprobe.d/}}.}}
 +
 +
==Obtaining information==
 +
 +
* Format the contents of {{Filename|/proc/modules}} and show what kernel modules are currently loaded:
 +
$ lsmod
 +
 +
* Use {{Codeline|modinfo}} to show information about a module:
 +
$ modinfo ''module_name''
 +
 +
* Use {{Codeline|modprobe}} to list the dependencies of a module (or alias), including the module itself:
 +
$ modprobe --show-depends ''module_name''
 +
 +
===Configuration===
 +
 +
If you want to display the comprehensive configuration of all the modules you can use the command:
 +
 +
$ modprobe -c | less
 +
 +
To display the configuration of a particular module, use:
 +
 +
$ modprobe -c | grep ''module_name''
  
 
==Loading==
 
==Loading==
Line 23: Line 44:
 
  # modprobe ''module_name''
 
  # modprobe ''module_name''
  
For informations on loading modules automatically at system boot, see [[rc.conf#Hardware|rc.conf]].
+
For information on loading modules automatically at system boot, see [[rc.conf#Hardware|rc.conf]].
  
 
==Removal==
 
==Removal==
Line 33: Line 54:
  
 
  # rmmod ''module_name''
 
  # rmmod ''module_name''
 
==Configuration==
 
If you want to display the comprehensive configuration of all the modules you can use the command:
 
 
$ modprobe -c
 
 
Since the output of that command will probably turn out to be very long, you can page it with:
 
 
$ modprobe -c | less
 
 
To display the configuration of a particular module, use:
 
 
$ modprobe -c | grep ''module_name''
 
  
 
==Options==
 
==Options==
Line 120: Line 128:
 
...}}
 
...}}
  
==Dependencies==
+
==See also==
The following commands can help determine the dependencies of a module from the module itself.
+
  
* Format the contents of {{Filename|/proc/modules}} and show what kernel modules are currently loaded:
 
$ lsmod
 
 
* Use {{Codeline|modinfo}} to show information about {{Codeline|MODULE_1}}:
 
$ modinfo MODULE_1
 
 
* Use {{Codeline|modprobe}} to show information about {{Codeline|MODULE_2}} (including aliases and install commands): 
 
$ modprobe --show-depends MODULE_2
 
 
==See also==
 
 
*http://linuxmanpages.com/man5/modprobe.conf.5.php
 
*http://linuxmanpages.com/man5/modprobe.conf.5.php
 
*[[Disabling IPv6]]
 
*[[Disabling IPv6]]
 
*[[Disable PC Speaker Beep]]
 
*[[Disable PC Speaker Beep]]

Revision as of 13:37, 7 November 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

This article covers the various methods for operating with kernel modules.

Overview

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Kernel modules#)

For a module to be recognized as such, it has to be compiled as a module in the kernel configuration (the line related to the module will therefore display the letter M).

Modules are stored in Template:Filename (use the command Template:Codeline to print your current kernel release).

The Template:Codeline command handles the addition and removal of modules from the Linux kernel.

The Template:Filename directory can be used to pass module settings to udev, which will use Template:Codeline to manage the loading of the modules during system boot. You can use configuration files with any name in the directory, given that they end with the Template:Filename extension.

Note: Module names often use underscores ("_") or dashes ("-"), however those symbols are interchangeable both when using the Template:Codeline command and in configuration files in Template:Filename.

Obtaining information

  • Format the contents of Template:Filename and show what kernel modules are currently loaded:
$ lsmod
$ modinfo module_name
  • Use Template:Codeline to list the dependencies of a module (or alias), including the module itself:
$ modprobe --show-depends module_name

Configuration

If you want to display the comprehensive configuration of all the modules you can use the command:

$ modprobe -c | less

To display the configuration of a particular module, use:

$ modprobe -c | grep module_name

Loading

To manually load (or add) a module, run:

# modprobe module_name

For information on loading modules automatically at system boot, see rc.conf.

Removal

Occasionally you could need to remove (or unload) a module; in this case use the following command:

# modprobe -r module_name

Or, alternatively:

# rmmod module_name

Options

To pass a parameter to a kernel module you can use a modprobe conf file or use the kernel command line.

Using files in /etc/modprobe.d/

To pass options to a module using modprobe config files, a .conf file with any name (you can even use Template:Filename) needs to be placed in Template:Filename with this syntax: Template:File for example: Template:File

Using kernel command line

If the module is built into the kernel you can also pass options to the module using the kernel command line (e.g. in GRUB, LILO or Syslinux) using the following syntax:

modname.parametername=parametercontents

for example:

thinkpad_acpi.fan_control=1

Aliasing

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Kernel modules#)
Template:File

Some modules have aliases which are used to autoload them when they are needed by an application. Disabling these aliases can prevent auto-loading, but will still allow the modules to be manually loaded. Template:File

Blacklisting

Blacklisting, in the context of kernel modules, is a mechanism to prevent the kernel module from loading. This could be useful if, for example, the associated hardware is not needed, or if loading that module causes problems: for instance there may be two kernel modules that try to control the same piece of hardware, and loading them together would result in a conflict.

Some modules are loaded as part of the initramfs. Template:Codeline will print out all autodetected modules: to prevent the initramfs from loading some of those modules, blacklist them in Template:Filename. Running Template:Codeline will list all modules pulled in by the various hooks (e.g. filesystem hook, SCSI hook, etc.). Remember to rebuild the initramfs once you have blacklisted the modules and to reboot afterwards.

Warning: Blacklisting modules in Template:Filename has been obsoleted and no longer works in Template:Package Official 2011.06.1-1, so you will have to use one of the following methods.

Using files in /etc/modprobe.d/

Create a Template:Filename file inside Template:Filename and append a line for each module you want to blacklist, using the Template:Codeline keyword. If for example you want to prevent the Template:Codeline module from loading:

Template:File

Note: The Template:Codeline command will blacklist a module so that it will not be loaded automatically, but the module may be loaded if another non-blacklisted module depends on it or if it is loaded manually.

However, there is a workaround for this behaviour; the Template:Codeline command instructs modprobe to run a custom command instead of inserting the module in the kernel as normal, so you can force the module to always fail loading with:

Template:File

This will effectively "blacklist" that module and any other that depends on it.

Using kernel command line

Tip: This is useful in an emergency where a broken module makes it impossible to boot your system.

You can also blacklist modules on the kernel command line (e.g. in GRUB, LILO or Syslinux) using the following syntax:

modprobe.blacklist=modname1,modname2,modname3

Alternatively:

modname.disable=1

Examples using GRUB

Template:File

Template:File

See also