Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
additional commands that are required and which have not been invoked already. The normal
location of this script is /etc/rc.d/rc.local.
Therefore if the modprobe command is added to that script it will be executed at the end, and
before a login shell prompt is provided. Determine the location of modprobe. If, for example, it
is /sbin/modprobe, then the end of the rc.local file should look something like this:
# Put your required modprobe command here:
/sbin/modprobe name-of-module
Note that if the module in question requires options, then a place to put these is in
/etc/modprobe.conf, because when modprobe runs it will read that configuration file and pick up
any required options from there.
To load a module by filename (i.e. one that is not installed in /lib/modules/$(uname -r)/):
# insmod filename [args]
To unload a module:
# modprobe -r module_name
Or, alternatively:
# rmmod module_name
Check this link for more info on how to work with modules:
Kernel modules
Related articles
Boot debugging
Kernels
Kernel parameters
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.
Contents
1 Overview
2 Obtaining information
6 Aliasing
7 Blacklisting
8 Troubleshooting
o
9 See also
Overview
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 M).
Modules are stored in /usr/lib/modules/kernel_release. You can use the command uname
-r to get your current kernel release version.
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
To show what kernel modules are currently loaded:
$ lsmod
List the dependencies of a module (or alias), including the module itself:
$ modprobe --show-depends module_name
To load a module:
# modprobe module_name
To load a module by filename (i.e. one that is not installed in /lib/modules/$(uname -r)/):
# insmod filename [args]
To unload a module:
# modprobe -r module_name
Or, alternatively:
# rmmod module_name
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 /etc/mkinitcpio.conf or use the
modconf hook, so that it will be included in the initramfs.
For example:
thinkpad_acpi.fan_control=1
Aliasing
Aliases are alternate names for a module. For example: alias my-mod
really_long_modulename means you can use modprobe my-mod instead of modprobe
Create an alias:
/etc/modprobe.d/myalias.conf
alias mymod really_long_module_name
Some modules have aliases which are used to automatically load them when they are needed by
an application. Disabling these aliases can prevent automatic loading but will still allow the
modules to be manually loaded.
/etc/modprobe.d/modprobe.conf
# Prevent Bluetooth autoload
alias net-pf-31 off
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. mkinitcpio -M will print out all
automatically detected 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. filesystems hook, block hook, etc.). Remember
to add that .conf file to the FILES section in /etc/mkinitcpio.conf, if you have not done so
already, and rebuild the initramfs once you have blacklisted the modules, and 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:
/etc/modprobe.d/nobeep.conf
# 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
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:
/etc/modprobe.d/blacklist.conf
...
install module_name /bin/false
...
This will effectively blacklist that module and any other that depends on it.
Troubleshooting
Modules do not load
In case a specific module do not loads and the boot log (accessible with journalctl -b) says
that the module is blacklisted, but the directory /etc/modprobe.d/ does not show a
corresponding entry, check another modprobe source folder at /usr/lib/modprobe.d/ for
blacklisting entries.
Related articles
Kernel
Kernel modules
Sometimes you may wish to compile Linux's Kernel module without recompiling whole kernel.
Note: You can only replace existing module if it is compiled as module (M) and not
builtin (y) into kernel.
Firstly you will need to install build dependencies such as compiler (base-devel) and linuxheaders.
Next you will need to get source code for exact kernel version you are running. You may try use
newer kernel sources but most likely compiled module will not load.
Find kernel version with
$ uname -r
Then you need to copy your current existing kernel configuration to this build dir
$ cp /usr/lib/modules/`uname -r`/build/.config ./
$ cp /usr/lib/modules/`uname -r`/build/Module.symvers ./
Next ensure configuration is adjusted for kernel sources (if you are using kernel sources for exact
current version then it should not ask anything, but for newer sources than current kernel you
might be asked about new options).
Also if module you want to compile have some compilation options such as debug build you can
also adjust them with any of make config/menuconfig/xconfig (see README)
$ make oldconfig
And finally compile wanted module by specifying its directory. (You can find module location
with modinfo or find)
$ make M=fs/btrfs
Now after successful compilation you just need to gzip and copy it over for your current kernel.
If you are replacing some existing module you will need to overwrite it (and remember that
reinstalling linux will replace it with default module)
$ gzip fs/btrfs/btrfs.ko
$ sudo cp -f fs/btrfs/btrfs.ko.gz /usr/lib/modules/`uname
-r`/kernel/fs/btrfs/
But if you are adding new module you can just copy it to extramodules (note, this is just example
as btrfs will not get loaded from here)
$ sudo cp fs/btrfs/btrfs.ko.gz /usr/lib/modules/`uname -r`/extramodules/
If you are compiling module for early boot which is copied to Initramfs then you must remember
to regenerate it with (otherwise your compiled module will not be loaded)
$ sudo mkinitcpio -p linux
Kernel parameters
There are three ways to pass options to the kernel and thus control its behaviour:
1. When building the kernel. See Kernel Compilation for details.
2. When starting the kernel (usually, when invoked from a boot loader).
3. At runtime (through the files in /proc and /sys). See sysctl for details.
This page now explains in more detail the second method and shows a list of most used kernel
parameters in Arch Linux.
Contents
1 Configuration
o 1.1 Syslinux
o
1.2 GRUB
1.4 LILO
1.5 Gummiboot
1.6 rEFInd
1.7 EFISTUB/efibootmgr
2 Parameter list
3 See also
Configuration
Note: You can check the parameters your system was booted up with by running $
cat /proc/cmdline and see if it includes your changes.
Kernel parameters can be set either temporarily by editing the boot menu when it shows up, or
by modifying the boot loader's configuration file.
Here we are adding the parameters quiet and splash to Syslinux, GRUB, GRUB Legacy,
LILO, Gummiboot and rEFInd.
Syslinux
Press Tab when the menu shows up and add them at the end of the string:
linux /boot/vmlinuz-linux root=/dev/sda3 initrd=/boot/initramfslinux.img quiet splash
Press Enter to boot with these parameters.
Press e when the menu shows up and add them on the linux line:
linux /boot/vmlinuz-linux root=UUID=978e3e81-8048-4ae1-8a06-aa727458e8ff
quiet splash
Press b to boot with these parameters.
To make the change persistent after reboot, while you could manually edit
/boot/grub/grub.cfg with the exact line from above, for beginners it's
recommended to:
Edit /etc/default/grub and append your kernel options to the
GRUB_CMDLINE_LINUX_DEFAULT line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
And then automatically re-generate the grub.cfg file with:
# grub-mkconfig -o /boot/grub/grub.cfg
Press e when the menu shows up and add them on the kernel line:
For more information on configuring GRUB Legacy, see the GRUB Legacy article.
LILO
Press e when the menu appears and add the parameters to the end of the
string:
initrd=\initramfs-linux.img root=/dev/sda2 quiet splash
Press Enter to boot with these parameters.
Note: If you have not set a value for menu timeout, you will need to hold Space
while booting for the Gummiboot menu to appear.
"root=PARTUUID=978e3e81-8048-4ae1-8a06-aa727458e8ff quiet
For more information on configuring kernel parameters in rEFInd, see Configuring the rEFInd
Bootmanager
EFISTUB/efibootmgr
See EFISTUB#Using UEFI directly (efibootmgr).
Parameter list
Parameters always come in parameter or parameter=value. All of these parameters are casesensitive.
Note: Not all of the listed options are always available. Most are associated with
subsystems and work only if the kernel is configured with those subsystems built in.
They also depend on the presence of the hardware they are associated with.
parameter
Description
root=
Root filesystem.
ro
rw
initrd=
init=
init=/bin/sh
Boot to shell.
systemd.unit=
systemd.unit=multi
Boot to a specified runlevel.
-user
systemd.unit=resc
Boot to single-user mode (root).
ue
nomodeset
zswap.enabled
Enable Zswap.
video=<videosettin
Override framebuffer video defaults.
g>
mkinitcpio uses ro as default value when neither rw or ro is set by the boot loader. Boot
loaders may set the value to use, for example GRUB uses rw by default (see FS#36275 as a
reference).
For a complete list of all options, please see the kernel documentation.