GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing wiki.archlinux.org — Kernel module - ArchWiki (Redirected from Kernel modules) Related articles Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system. To create a kernel module, you can read The Linux Kernel Module Programming Guide. A module can be configured as built-in or loadable. To dynamically load or remove a module, it has to be configured as a loadable module in the kernel configuration (the line related to the module will therefore display the letter To rebuild a kernel module automatically when a new kernel is installed, see Dynamic Kernel Module Support (DKMS). Obtaining informationUsually modules depend on the kernel release and are stored in the Tip Run
uname -r (or uname --kernel-release) to get your current kernel release.Note Module and alias names often use underscores (
_) or dashes (-); however, those symbols are interchangeable when using the modprobe command and in configuration files in /etc/modprobe.d/ (automatic conversion to underscores is performed, see modprobe(8) § DESCRIPTION and modprobe.d(5) § DESCRIPTION).To show what kernel modules are currently loaded: $ lsmod To show information about a module: $ modinfo module_name To list the options that are set for a loaded module use systool(1) from sysfsutils: $ systool -v -m module_name To display the comprehensive configuration of all the modules: $ modprobe -c | less To display the configuration of a particular module: $ modprobe -c | grep module_name List the dependencies of a module (or alias), including the module itself: $ modprobe --show-depends module_name Automatic module loadingToday, all necessary modules loading is handled automatically by udev, so if you do not need to use any out-of-tree kernel modules, there is no need to put modules that should be loaded at boot in any configuration file. However, there are cases where you might want to load an extra module during the boot process, or blacklist another one for your computer to function properly. Early module loadingEarly module loading depends on the initramfs generator used: Note The initramfs image may not contain the kernel modules asked for in
/etc/modules-load.d/, it also may lack the files that have been set in that folder (see #systemd).systemdKernel modules can be explicitly listed in files under /etc/modules-load.d/virtio-net.conf # Load virtio_net.ko at boot virtio_net See modules-load.d(5) for more details. Manual module handlingKernel modules are handled by tools provided by the kmod package, which is installed as a dependency of a kernel package. You can use these tools manually. To load a module: # modprobe module_name Note If you have upgraded your kernel but have not yet rebooted, modprobe will fail with no error message and exit with code
1, because the path /usr/lib/modules/kernel_release/ no longer exists. Check manually if this path exists when modprobe failed to determine if this is the case.To load a module by a file name—i.e. one that is not installed in the # insmod file_name module_options # modprobe file_name To unload—remove—a module, use any of: # rmmod module_name # modprobe -r module_name # modprobe --remove module_name Setting module optionsTo pass a parameter to a kernel module, you can pass them manually with modprobe or assure certain parameters are always applied using a modprobe configuration file or by using the kernel command line. If the module is built into the kernel, the kernel command line must be used and other methods will not work. Using modprobeThe basic way to pass parameters to a module is using the modprobe command. Parameters are specified on command line using simple # modprobe module_name parameter_name=parameter_value Using modprobe.dConfiguration files in the $ systemd-analyze cat-config modprobe.d The syntax is: /etc/modprobe.d/file_name.conf options module_name parameter_name=parameter_value Note All options for a given module must be defined in a single line. New
options line with the same module name replaces the previous one.Multiple module parameters are separated by spaces, in turn a parameter can receive a list of values which is separated by commas: /etc/modprobe.d/file_name.conf options module_name param1=value1 param2=value2a,value2b … For example: /etc/modprobe.d/thinkfan.conf # On ThinkPads, this lets the 'thinkfan' daemon control fan speed options thinkpad_acpi fan_control=1 Note If any of the affected modules is loaded from the initramfs, then you will need to add the appropriate .conf file to
FILES in mkinitcpio.conf or use the modconf hook, then regenerate the initramfs to include the .conf file. To see the contents of the default initramfs use lsinitcpio.Using kernel command lineYou can also pass options to the module using the kernel command line. This is the only working option for modules built into the kernel. For all common boot loaders, the following syntax is correct: module_name.parameter_name=parameter_value For example: thinkpad_acpi.fan_control=1 Simply add this to the appropriate line in your boot loader configuration, as described in Kernel parameters#Boot loader configuration. AliasingAliases are alternate names for a module. For example: /etc/modprobe.d/myalias.conf alias my-mod really_long_module_name Aliases can be internal—contained in the module itself. Internal aliases are usually used for #Automatic module loading when it is needed by an application, e.g. when the kernel detects a new device. To see the module internal aliases: $ modinfo --field=alias module_name To see both configured and internal aliases: $ modprobe --showconfig | grep '\<module_name$' BlacklistingBlacklisting, 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. Tip Do not confuse the blacklisting as a generic term with using the
blacklist keyword as a blacklisting particular case.Some modules are loaded as part of the initramfs. Using modprobe.daliasDisable an alias by overriding. For example, to prevent Bluetooth module autoloading (assuming a module named /etc/modprobe.d/modprobe.conf alias net-pf-31 off Note Alias overriding can prevent automatic module loading, but will still allow the module to be loaded—both automatically and manually—by another alias or the module name.
blacklistTo disable all internal aliases for a given module use the /etc/modprobe.d/nobeep.conf blacklist pcspkr Note The
blacklist configuration command—as it deals with aliases—has the same drawback as the alias one does: automatic loading can be prevented, but the module still may be loaded manually, or automatically if another module depends on it.installThere is a workaround for the behaviour described in the #alias and #blacklist notes. The /etc/modprobe.d/blacklist.conf install module_name /bin/true You can force the module to always fail loading with Using kernel command lineTip This can be very useful if a broken module makes it impossible to boot your system.
You can also blacklist modules from the boot loader boot entry configuration. Simply add Note
Another use case for a command line option is to disable hardware-specific components of a module without disabling the module entirely. For example, disabling a microphone while retaining other sound out options. See BBS#303475 for a few examples. TroubleshootingModule does not loadIn case a specific module does not load and the boot log (accessible by running A module will not be loaded if the "vermagic" string contained within the kernel module does not match the value of the currently running kernel. If it is known that the module is compatible with the current running kernel the "vermagic" check can be ignored with Warning Ignoring the version checks for a kernel module can cause a kernel to crash or a system to exhibit undefined behavior due to incompatibility. Use
--force-vermagic only with the utmost caution.See also
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |