Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Linux Loadable and built-in modules

What's the difference between loadable modules and built-in (statically linked) modules?

I got this question while finding out an answer for difference between system calls subsys_initcall() and module_init()

like image 754
Sagar Jain Avatar asked Apr 08 '14 06:04

Sagar Jain


People also ask

Which modules are loaded Linux?

Under Linux use the file /proc/modules shows what kernel modules (drivers) are currently loaded into memory.

What is difference between module and package in Linux?

A module is a set of functions, types, classes, ... put together in a common namespace. A library is a set of modules which makes sense to be together and that can be used in a program or another library. A package is a unit of distribution that can contain a library or an executable or both.

What are the two important characteristics of Linux loadable modules?

The Linux loadable modules have two important characteristics: Dynamic linking: A kernel module can be loaded and linked into the kernel while the kernel is already in memory and executing. A module can also be un- linked and removed from memory at any time. Stackable modules: The modules are arranged in a hierarchy.

What are the advantages of loadable kernel modules?

Loadable kernel modules have several advantages over monolithic "blobs" of code in the kernel: * Device drivers don't have to be hard-coded into the kernel. For example, if a new chip-set comes out that powers many webcams, that kernel module can simply be loaded instead of recompiling the kernel with the new module.


1 Answers

Linux kernel supports inserting of modules (aka device drivers) in two ways:

  1. Built-in kernel modules - When the kernel is booted up, the kernel automatically inserts this driver in to the kernel (it's more like it is already part of the kernel code).
  2. Loadable kernel module (LKM) - A driver that is not automatically loaded by the kernel, the user can insert this module at run-time by insmod driver.ko or modprobe driver.ko

The advantage the loadable modules have over the built-in modules is that you can load unload them on run-time. This is good if you are working on a module and you need to test it. Every time you test it and you need to make changes to it, you can easily unload it (rmmod driver.ko or modprobe -r driver.ko) and then after making changes, you can insert it back. But for the built-in modules if you need to make any changes in the module then you need to compile the whole kernel and then reboot the system with the new image of the kernel.

Configuration:
You can configure a module to be either of the two by editing the .config file in the root folder of your kernel source:

DRIVER_1=y // y indicate a builtin module
DRIVER_1=m //m inicates a loadable module

Note: lsmod displays only the dynamically loaded modules not the built-in ones.

Read on: http://www.tldp.org/HOWTO/Module-HOWTO/x73.html

like image 62
brokenfoot Avatar answered Oct 12 '22 01:10

brokenfoot