I wish to know few things which makes Linux different from other Operating systems, i.e., about the Loadable Kernel Modules.
- Brief intro on how LKMs works?
- In which language a new module is written?
- How to add a new module to Linux Kernel? and
- Possibility of a wreak havoc when a new module is inserted to the kernel.
1 Answer
Read this for full documentation
If you want to add code to a Linux kernel, the most basic way to do that is to add some source files to the kernel source tree and recompile the kernel. In fact, the kernel configuration process consists mainly of choosing which files to include in the kernel to be compiled.
But you can also add code to the Linux kernel while it is running. A chunk of code that you add in this way is called a loadable kernel module.LKM
There are six main things LKMs are used for:
- Device drivers.
- Filesystem drivers.
- System calls.
- Network drivers.
- TTY line disciplines.
- Executable interpreters.
A module is mainly written in C language and maybe include assembly in some cases.
To insert a module use
insmod moduleTo remove a mdoule use
rmmod module