uname -r
This will report the kernel version. We could also read this from the file in the procfs:
cat /proc/version
The uname command can be useful. If we want to go the the directory for the running kernel modules we can use the command:
cd /lib/modules/$(uname -r)
To list the running modules, modules loaded by the kernel we can use the command:
lsmod
From the output we can see that the module cdrom is in use by the module sr_mod, note the used by column. We can can’t unload the cdrom module until the module sr_mod is unloaded. We can also view the loaded modules via the file /proc/modules.
To unload module we can use rmmod or modprobe -r:
modprobe -r sr_mod OR
rmmod sr_mod
modprobe -r cdrom OR
rmmmod cdrom
Loading the modules can be made with modprobe or inssmod. Modprobe is far more convenient:
◈ Does not need to full path whereas insmod does
◈ Will load the required modules where insmod needs you to load each module in the correct order
To show you this we can use modprobe with the -v option. With both sr_mod and cdrom modules unloaded:
modprobe -v sr_mod
We can see the insmod is used in the background that needs the full path to the module and the dependency module is also loaded. The dependencies are maintained via the file:
/lib/modules/$(uname -r)/modules.dep
The command modinfo can be used to display information about a module including the full path to the module file and and options that it may accept during the load phase. These options can be applied automatically each time the module loads though configuration files in /etc/modprobe.d/. We can also apply aliases to module names here, this is often when a program will call one module but you would like another used:
alias kangaroo cdrom
Now we can use
modprobe kangaroo
And the cdrom module will load.
0 comments:
Post a Comment