[SOLVED] Comprehension question: Are drivers generally compiled as loadable modules?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
Comprehension question: Are drivers generally compiled as loadable modules?
I recently read that the kernel now exceeds 15 million lines of code, each version adding about 200.000 to 300.000 new lines. By far the most of these lines constitute the sources of drivers.
How is this handled, are those drivers just loadable modules and those statistics just show all available source code? Or does each kernel of an average distro contain all (most) drivers? Can anybody point me to sources to read up on that?
Most will probably be for loadable modules. Some is in the kernel proper, but only included if you select that option when building the kernel. Server distributions such as Red Hat may include fewer options. A server is less likely to need the last est hardware drivers. Home users on the other hand want their new wireless device to work.
Remember that many kernel build options can be loadable, or built in. It's up to you when you build your own kernel.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Original Poster
Rep:
How is it done? I mean, runs the kernel a hardware scan and decides what to load additionally? Or are all available modules loaded regardless of their being needed or not? How does SuSE handle that, would you know?
Firstly, if you don't configure a kernel module, it can't be loaded period. It won't be built as a .ko module either. If it is, the udev system will detect it and the kernel module will be loaded (modprobed). Also look at the documentation for depmod.conf. It or the files in /etc/depmod.d/ determine how modules are loaded. Which options to use, and if it's name is aliased. Sometimes module options are given on the kernel boot line (menu.lst). Some kernel modules are added to the initrd file, so the device can be loaded before the filesystem is loaded.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Original Poster
Rep:
Quote:
Originally Posted by jschiwal
Firstly, if you don't configure a kernel module, it can't be loaded period. It won't be built as a .ko module either.
Is it then automatically part of the monolithic kernel, i.e. inbuilt?
Quote:
Originally Posted by jschiwal
If it is, the udev system will detect it and the kernel module will be loaded (modprobed).
When requested, i.e. needed by some event in the running system if I understand this right.
Quote:
Originally Posted by jschiwal
Also look at the documentation for depmod.conf. It or the files in /etc/depmod.d/ determine how modules are loaded. Which options to use, and if it's name is aliased. Sometimes module options are given on the kernel boot line (menu.lst). Some kernel modules are added to the initrd file, so the device can be loaded before the filesystem is loaded.
Things may have changed some under systemd.
Ahh yes, this makes things more clear. Thank you .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.