I have been interested in kernel development for a while. What I am wondering is whether the kernel source code contains any code about the hardware components.

In other words, are device drivers part of kernel source code?

If they are part of kernel source code, how can it be possible?

By using a virtual machine or dual boot, we can set up Linux in any computer. How does Linus Torvalds write it to be compatible with all computers and their hardware components?

I think that device drivers are not part of the kernel.

  • 5
    In fact, device drivers are included in the kernel source code which you can easily verify by downloading it and browsing, for example, drivers/net/wireless. Like Santa Claus with his elves, Mr. Torvalds has many helpers. – chili555 Nov 20 '18 at 14:09

Device drivers are in the kernel.

Linus wrote the original Linux kernel by himself, and remains very much involved (last I heard about it anyway) but now there are thousands of people developing for the Linux kernel. These folks include employees of companies like Intel who write drivers for their devices for the Linux kernel (and get paid to do it).

Note that one driver can work for many different devices. For example, i915 is the kernel's Intel CPU driver. There doesn't need to be a driver for every single different Intel CPU.

Loosely described, Linux kernel development is a huge, widely distributed project overseen by Linus and other core developers, with people contributing as their full time job, part of their work, as a hobby or project, all communicating through mailing lists. Anyone can write a patch for the kernel, patch the kernel, and use and distribute their patched kernel. But if your patch is so great it really ought to be in the kernel by default, with some feedback and help from others, it might get merged into a future kernel release. This open and diffuse model of development, with many minds and perspectives on the job, accounts somewhat for how the Linux kernel manages to support such a wide range of hardware. Here's the documentation for kernel development.

As chilli555 pointed out you can download the kernel source code and find device drivers. To do this, enable source repositories, create a directory in your home and enter it, and from there run (sudo is not needed):

apt source linux
| improve this answer | |
  • Can I ask another question in this comment section? It will be a very short question. – Goktug Nov 21 '18 at 18:34
  • @Goktug yes, feel free - if it doesn't seem within the scope of this question, I can say so :) – Zanna Nov 22 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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