Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I do a lspci -k on my Kubuntu with a 3.2.0-29-generic kernel I can see something like this:

01:00.0 VGA compatible controller: NVIDIA Corporation G86 [Quadro NVS 290] (rev a1)
    Subsystem: NVIDIA Corporation Device 0492
    Kernel driver in use: nvidia
    Kernel modules: nvidia_current, nouveau, nvidiafb

There is a kernel driver nvidia and kernel modules nvidia_current, nouveau, nvidiafb.

Now I wondered what might be the difference between Kernel drivers and Kernel modules?

share|improve this question
add comment

5 Answers

up vote 19 down vote accepted

A kernel module is a bit of compiled code that can be inserted into the kernel at run-time, such as with insmod or modprobe.

A driver is a bit of code that runs in the kernel to talk to some hardware device. It "drives" the hardware. Most every bit of hardware in your computer has an associated driver[*]. A large part of a running kernel is driver code; the rest of the code provides generic services like memory management, IPC, scheduling, etc.

A driver may be built statically into the kernel file on disk. (The one in /boot, loaded into RAM at boot time by the boot loader early in the boot process.) A driver may also be built as a kernel module so that it can be dynamically loaded later. (And then maybe unloaded.)

Standard practice is to build drivers as kernel modules where possible, rather than link them statically to the kernel, since that gives more flexibility. There are good reasons not to, however:

  • Sometimes a given driver is absolutely necessary to help the system boot up. That doesn't happen as often as you might imagine, due to the initrd feature.

  • Statically built drivers may be exactly what you want in a system that is statically scoped, such as an embedded system. That is to say, if you know in advance exactly which drivers will always be needed and that this will never change, you have a good reason not to bother with dynamic kernel modules.

Not all kernel modules are drivers. For example, a relatively recent feature in the Linux kernel is that you can load a different process scheduler.

[*] One exception to this broad statement is the CPU chip, which has no "driver" per se. Your computer may also contain hardware for which you have no driver.

share|improve this answer
    
Perfectly explained, thanks! –  Ian Oct 26 '12 at 17:57
1  
Statically building every kernel module can also be a security feature (if you disable module loading) by disallowing any modification (or potential corruption) to the kernel code after bootup. –  Totor Mar 25 '13 at 21:44
add comment

To answer your specific question about the lspci output, the "kernel driver" line refers to which driver is currently bound to the card, in this case the proprietary nvidia driver. The "kernel modules" line lists all of the drivers known to be capable of binding to this card. Here, the proprietary driver shows up it a different name, probably due to how lspci found the driver and its filename versus the name coded into the driver itself.

share|improve this answer
add comment

According to this nice tutorial :

...one type of module is the device driver, which allows the kernel to access hardware connected to the system.

So, if we try to draw a tree, we will have "Device driver" which inherits from (extends) Module, and which has more specific characteristics, between which we find "accessing to hardware"...

share|improve this answer
add comment

My answer will go with Jim. A kernel driver is a program (kernel module) that is designed to drive a piece of hardware. The lspci output says nvidia is the kernel driver as it is the loaded module for the device. Along with it comes other available kernel modules available.

I'll add that the commands in linux to list and remove drivers are lsmod and rmmod respectively. Which says list module and remove module.

share|improve this answer
add comment

All Drivers are modules. All modules are not drivers.

Modules can be inserted at runtime. Modules/Drivers can be statically compiled along with the kernel also.

Typical module init has

module_init(init_fn);
init_fn()
{
   /* some code */
}

The same module can be made a driver

module_init(init_fn);
init_fn()
{
   device_register(&device);
   /* some code */
}
share|improve this answer
3  
Drivers aren't always modules, they can be included in the main kernel image. –  Gilles Sep 5 '12 at 22:06
1  
@Prabagaran: "All Drivers are modules. All modules are not drivers." This is contradictory. In mathematical terms, what you are saying is D -> M and M -> !D. This allows for D and !D. –  Francesco Turco Sep 13 '12 at 10:50
1  
I think he means "All drivers are modules. Not all modules are drivers". –  Renan Sep 14 '12 at 1:29
2  
@Renan: That would be correct, but if you look at the edit history for this answer somebody already tried to fix the mistake and the author reverted it. Normally I would just edit to fix the error and move on, but in this case I've -1'ed because it's just wrong and confusing the issue. –  Caleb Sep 25 '12 at 11:39
add comment

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.