Linux modules and how they work

In the /proc directory their is a file called modules which lists device drivers inserted in the Linux kernel.  How do these drivers work and what are their relationship with the device files in the /dev directory?

Phorious WhitmoreInformation TechnicianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel HelgenbergerCommented:
Basically, Unix/Linux is following the 'everything is a file' philosophy. Meaning, every device for instance is represented by a file, you can wipe/damage a Hard disk by copying something on its device file.

Kernel modules are like device drivers. If the kernel detects certain hardware, it will try to load the corresponding kernel module. This approach is called microlithic kernel (vs. the monolithic kernel, which would have all modules compiled in; they would always be loaded).
This is the reason why a linux installation will almost always work on different hardware if you move the root disk.
If for instance a kernel module for a raid controller is loaded, it will make the corresponding device nots ('mknod') for the disks in /dev.

Also, for documenting reasons, there is /proc - every device driver will create a file there where information about this diver and its devices is maintained. For instance, our raid controller would be represented there with a file stating the size of the disks and I/O - throughput. Some commands like iostat use the /proc filesystem.

While Linux cannot run without /dev, it can run without /proc perfectly. Proc is info for humans only.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.