# Managing the kernel modules

Linux device drivers come in the form of kernel modules - object files which may be loaded into the running kernel to extend its functionality. The list of currently loaded kernel modules can be obtained using the `lsmod` command, modules may be loaded using `modprobe`, and removed using `modprobe -r`. The `depmod` command may be used to regenerate the list of available modules (after installation of the new modules, for example), even though it is pretty unlikely that you will ever need to invoke it by hand.

Normally, the devices are detected and necessary kernel modules are loaded by `udev` during boot time. Occasionally, one may need finer control over the loading of kernel modules, for example to pass the additional parameters to the module, force loading of some modules on startup, or prevent certain module(s) from being loaded.

If some modules are not loaded automatically by `udev`, but you would like them to be loaded during boot, it is possible to force it by listing the names of the modules in `/etc/modules`. This will be scanned for the names of the modules (one name per line), which will then be loaded using `modprobe`. For example, a typical `/etc/modules` might look like:

    loop
    sbp2

To find out what parameters are accepted by a given module, you can use the `modinfo` command, for example:

    # modinfo loop
    filename:       /lib/modules/3.2.0-2-686-pae/kernel/drivers/block/loop.ko
    alias:          devname:loop-control
    alias:          char-major-10-237
    alias:          block-major-7-*
    license:        GPL
    depends:
    intree:         Y
    vermagic:       3.2.0-2-686-pae SMP mod_unload modversions 686
    parm:           max_loop:Maximum number of loop devices (int)
    parm:           max_part:Maximum number of partitions per loop device (int)

To add custom arguments to the modules loaded by `udev` early in the boot process, you need to create a custom configuration file for `modprobe`, which `udev` uses to load the modules. For example, to pass an `atapi_enabled=1` argument to the `libata` kernel module, create `/etc/modprobe.d/local.conf` file with the following line:

    options libata atapi_enabled=1

You can use any name ending in `.conf` for the configuration files in `/etc/modprobe.d` and put multiple `options` lines in the same file.

Sometimes two different modules claim support for the same device, usually because two slightly different versions of the device exist, requiring different kernel modules to operate. In such situation `udev` loads both kernel modules, with unpredictable results. To avoid this problem, you can prevent any module (let's say, `tulip`) from loading by creating a file containing the line:

    blacklist tulip

in `/etc/modprobe.d` directory. See the `modprobe` manual page (`man modprobe`) for much more information on configuring and using modprobe.