Professional Documents
Culture Documents
WHAT IS A KERNEL
2
BASIC FUNCTION OF KERNEL:
There are various tasks and functions of a kernel but some of the
important are given below:
3
Process Scheduling: Determine when processes should run and
for how long
5
What Is A Kernel Module?
6
Module Commands
There are a few commands that allow you to manipulate the kernel.
7
About modinfo
Description
8
About insmod
insmod /path/to/snd-usb-audio.ko
9
About lsmod
lsmod shows (or "lists") the status of modules in the Linux kernel.
Overview
Linux kernel modules (LKMs) are pieces of code which can be loaded
into the kernel much like a hot-swappable piece of hardware: they
can be inserted into the kernel and activated without the system
needing to be rebooted.
10
lsmod is a very simple program with no options: it nicely formats the
contents of the file /proc/modules, which contains information about
the status of all currently-loaded LKMs.
lsmod syntax
To list all active kernel modules, simply run lsmod at the command
line:
#lsmod
11
You'll see three columns of information:
12
Module: the name of the module. This is usually the name of the
module file, minus the extension (.o or .ko), but it may have a
custom name, which can be specified as an option when the module
is inserted with the insmod command.
ls -l /sys/class/net/<devname>/device/driver/module
[root@example lib]# ls -l
/sys/class/net/eth0/device/driver/module
lrwxrwxrwx 1 root root 0 Sep 14 19:32
/sys/class/net/eth0/device/driver/module ->
../../../../module/e1000
15
About modprobe
modprobe examples
sudo depmod -a
17
sudo modprobe your-kernel-module
About Modprobe
These commands perform the following operations:
In the first command, we use ln to create a symbolic link to our
module file in the directory /lib/modules/kernel-release. The
command uname -r, enclosed in back quotes, is executed by the
shell and translates to the appropriate string representing our
kernel release version.
18
modprobe installs the kernel module.
How to Load and Unload Kernel Modules in Linux
Likewise without modules, the kernel would have to be built with all
functionalities integrated directly into the kernel image. This would
mean having bigger kernels, and system administrators would need
19
to recompile the kernel every time a new functionality is needed.
A simple example of a module is a device driver – which enables the
kernel to access a hardware component/device connected to the
system.
In Linux, all modules end with the .ko extension, and they are
normally loaded automatically as the hardware is detected at system
boot. However a system administrator can manage the modules
using certain commands.
To list all currently loaded modules in Linux, we can use the lsmod
(list modules) command which reads the contents of /proc/modules
like this.
20
To list all currently loaded modules in Linux, we can use the lsmod
(list modules) command which reads the contents of /proc/modules
like this.
# lsmod
List Kernel Modules in Linux
Module Size Used by
rfcomm 69632 2
pci_stub 16384 1
vboxpci 24576 0
vboxnetadp 28672 0
vboxnetflt 28672 0
21
…………
How to Load and Unload (Remove) Kernel Modules in Linux
# sysctl -p
If you want to view the complete list of Kernel parameters, just do:
25
systctl -a|less
For Example:
# sysctl -a | grep -i dev.parport.parport0.devices.lp.timeslice
dev.parport.parport0.devices.lp.timeslice = 200
Please note that the first characters in each line match the names
of the directories inside /proc/sys
# ls /proc/sys
crypto debug dev fs kernel net sunrpc vm
# dev.parport.parport0.devices.lp.timeslice
# cd /proc/sys/dev/parport/parport0/devices/lp/
# cat timeslice
26
200
END of this Course Module.
Thanks
27