Manage/Query kernel and kernel modules at runtime (201.5)

Candidates should be able to manage and/or query a 2.6.x kernel and its loadable modules.

Key Knowledge Areas:

Use command-line utilities to get information about the currently running kernel and kernel modules.
Manually load and unload kernel modules.
Determine when modules can be unloaded.
Determine what parameters a module accepts.
Configure the system to load modules by names other than their file name.
The following is a partial list of used files, terms, and utilities:

/lib/modules/kernel-version/modules.dep
module configuration files in /etc
/proc/sys/kernel/
depmod
insmod
lsmod
rmmod
modinfo
modprobe
uname
insmod
insmod is a trivial program to insert a module into the kernel. usage: insmod [filename] [module options ...]

modprobe
modprobe inserts or removes a module and all of its dependencies into the kernel.

lsmod
lsmod is a trivial program which nicely formats the contents of the /proc/modules, showing which kernel modules are currently loaded.

rmmod
rmmod is a trivial program to remove a module from the kernel.

modinfo
modinfo extracts information from the Linux kernel modules given on the command line. If the module name is not a filename, then the /lib/modules/version directory is searched.

modinfo by default lists each attribute of the module in form fieldname : value, for easy reading. The filename is listed the same way (although it is not really an attribute).

usage: modinfo [-0] [-F field] [modulename|filename ...]

uname
uname prints system information. Parameters:

-a, --all print all information, in the following order, except omit -p and -i if unknown:
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type or "unknown"
-i, --hardware-platform print the hardware platform or "unknown"
-o, --operating-system print the operating system
Module dependencies
The /lib/modules/kernel-version/modules.depfile contains a list of module dependencies. It is generated by the depmod command. This file appears in every kernel version directory. The modprobe command uses this file to determine the order in which modules are loaded into or unloaded from the kernel. Modules are loaded from right to left and are removed from left to right.

Module configuration
Module configuration is handled in the file /etc/modules.conf. If this file does not exist the modprobe utility will try to read the /etc/conf.modules instead. The latter file is the historical name and is deprecated. It should be replaced by /etc/modules.conf. Note: On some systems this file is called /etc/modprobe.conf or there are configuration files in a directory called /etc/modprobe.d. More information on module configuration is given in the section Configuring modules in the previous chapter.

Kernel parameters
The directory /proc/sys/kernel contains several configuration files that influence the behaviour of the kernel.