Many device drivers and other kernel elements are compiled as modules. If a driver is compiled directly into the kernel, its code and static data occupy space even if they’re not used. But if the driver is compiled as a module, it requires memory only if memory is needed and subsequently loaded, into the kernel.
Interestingly, you won’t notice a performance hit for LKMs, so they’re a powerful means of creating a lean kernel that adapts to its environment based upon the available hardware and attached devices.
UW Linux Loadable Kernel Module
Create the Linux Loadable Kernel Module C file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
Next Create the Makefile.
1
|
|
Compile the Loadable Kernel Module using make -C /usr/src/linux-headers-`uname -r` SUBDIRS=$PWD modules
.
Then insert the new module using sudo insmod uw-lkm.ko
.
Finally, check the Log to confirm the new module is loaded using sudo dmesg | tail -1
.