Kernel module

From ArchWiki
Revision as of 20:54, 7 May 2012 by B adele (talk | contribs) (Using files in /etc/modprobe.d/)
Jump to navigation Jump to search

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.


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 module#)

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 /lib/modules/kernel_release (use the command uname -r to print your current kernel release).

The /sbin/modprobe command handles the addition and removal of modules from the Linux kernel.

The /etc/modprobe.d/ directory can be used to pass module settings to udev, which will use modprobe 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 .conf extension.

Note: Module names often use underscores (_) or dashes (-), however those symbols are interchangeable both when using the modprobe command and in configuration files in /etc/modprobe.d/.

Obtaining information

  • Format the contents of /proc/modules and show what kernel modules are currently loaded:
$ lsmod
  • Use modinfo to show information about a module:
$ modinfo module_name
  • Use modprobe to list the dependencies of a module (or alias), including the module itself:
$ modprobe --show-depends module_name
  • Use systool to list the options that are set for a loaded module:
$ systool -v -m module_name


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


Here is a nice bash function to be run as root that will show a list of all the currently loaded modules and all of their parameters, including the current value of the parameter. It uses /proc/modules to retrieve the current list of loaded modules, then access the module file directly with modinfo to grab a description of the module and descriptions for each param (if available), finally it accesses the sysfs filesystem to grab the actual parameter names and currently loaded values.

function aa_mod_parameters () 
    C=`tput op` O=$(echo -en "\n`tput setaf 2`>>> `tput op`");
    for mod in $(cat /proc/modules|cut -d" " -f1);
        [[ ! -d $md ]] && continue;
        d=`modinfo -d $m 2>$N | tr "\n" "\t"`;
        echo -en "$O$m$C";
        [[ ${#d} -gt 0 ]] && echo -n " - $d";
        for mc in $(cd $md; echo *);
            de=`modinfo -p $mod 2>$N | grep ^$mc 2>$N|sed "s/^$mc=//" 2>$N`;
            echo -en "\t$mc=`cat $md/$mc 2>$N`";
            [[ ${#de} -gt 1 ]] && echo -en " - $de";

Here is some sample output.

# aa_mod_parameters
>>> ehci_hcd - USB 2.0 'Enhanced' Host Controller (EHCI) Driver
        hird=0 - hird:host initiated resume duration, +1 for each 75us (int)
        ignore_oc=N - ignore_oc:ignore bogus hardware overcurrent indications (bool)
        log2_irq_thresh=0 - log2_irq_thresh:log2 IRQ latency, 1-64 microframes (int)
        park=0 - park:park setting; 1-3 back-to-back async packets (uint)

>>> processor - ACPI Processor Driver
        ignore_ppc=-1 - ignore_ppc:If the frequency of your machine gets wronglylimited by BIOS, this should help (int)
        ignore_tpc=0 - ignore_tpc:Disable broken BIOS _TPC throttling support (int)
        latency_factor=2 - latency_factor: (uint)

>>> usb_storage - USB Mass Storage driver for Linux
        delay_use=1 - delay_use:seconds to delay before using a new device (uint)
        option_zero_cd=1 - option_zero_cd:ZeroCD mode (1=Force Modem (default), 2=Allow CD-Rom (uint)
        quirks= - quirks:supplemental list of device IDs and their quirks (string)
        swi_tru_install=1 - swi_tru_install:TRU-Install mode (1=Full Logic (def), 2=Force CD-Rom, 3=Force Modem) (uint)

>>> video - ACPI Video Driver
        allow_duplicates=N - allow_duplicates: (bool)
        brightness_switch_enabled=Y - brightness_switch_enabled: (bool)
        use_bios_initial_backlight=Y - use_bios_initial_backlight: (bool)


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

# modprobe module_name

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


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


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 /etc/modprobe.d/modprobe.conf) needs to be placed in /etc/modprobe.d/ with this syntax:

options modname parametername=parametercontents

for example:

# On thinkpads, this lets the thinkfan daemon control fan speed
options thinkpad_acpi fan_control=1

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:


for example:



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 module#)
# Lets you use 'mymod' in MODULES, instead of 'really_long_module_name'
alias mymod really_long_module_name

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.

# Prevent autoload of bluetooth
alias net-pf-31 off

# Prevent autoload of ipv6
alias net-pf-10 off


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. mkinitcpio -M will print out all autodetected modules: to prevent the initramfs from loading some of those modules, blacklist them in /etc/modprobe.d/modprobe.conf. Running mkinitcpio -v 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.

Using files in /etc/modprobe.d/

Create a .conf file inside /etc/modprobe.d/ and append a line for each module you want to blacklist, using the blacklist keyword. If for example you want to prevent the pcspkr module from loading:

# Do not load the pcspkr module on boot
blacklist pcspkr
Note: The blacklist 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 install 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:

install MODULE_NAME /bin/false
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:




Examples using GRUB

kernel /vmlinuz-linux root=/dev/sda1 modprobe.blacklist=pcspkr,ipv6 ro
kernel /vmlinuz-linux root=/dev/sda1 pcspkr.disable=1 ipv6.disable=1 ro

See also