Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
    
So is that like a Windows device driver? –  Phenom Jul 31 '10 at 7:19
    
Yes, many modules are used for device drivers. However, there are other purposes, such as filesystems. –  Matthew Flaschen Jul 31 '10 at 7:22

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.