1

I was wondering if someone could explain what Linux kernel modules are to someone who comes from Windows?

3 Answers 3

3

It's a way of dynamically loading code into the Linux kernel, which the lowest level part of the GNU/Linux operating system. Windows device drivers are often used for similar purposes. You can read this somewhat old FAQ. Some things have changed, but the basic idea remains the same.

2
  • So is that like a Windows device driver?
    – Phenom
    Commented Jul 31, 2010 at 7:19
  • Yes, many modules are used for device drivers. However, there are other purposes, such as filesystems. Commented Jul 31, 2010 at 7:22
2

Kernel modules are stand-alone pieces of code that are loaded into the kernel to provide support for specific hardware.

For example the Linux kernel itself can't make use of a serial port (RS-232), but when you load the appropriate kernel module, it can.

The lsmod command will show you a list of currently loaded kernel modules.

1

Linux kernel modules are equivalent in concept to Windows device drivers.

To have a piece of hardware work, you need a driver for it in Windows, and you need a device driver kernel module for it in Linux.

Device drivers need to directly access hardware and therefore run in kernel mode. Normal user applications run in user mode. A user mode program has the protections of the CPU's MMU and cannot interfere with the operation of another user mode program or anything running in kernel mode. Things running in kernel mode do not have this protection, but can access hardware directly. So this is why they are called kernel modules.

You can build your own Linux kernel, and incorporate modules into the kernel. They then cease being modules at that point and are part of the kernel. Usually it's beneficial to only build in a small number of drivers needed for booting and let hardware detection load the rest of what's needed, although you can build a completely "static" kernel not relying on loading any modules if you wanted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .