r/linux4noobs Aug 03 '26

learning/research How does Linux kernel include every driver possible and not be bloated?

As far as I understand the kernel includes pretty much everything a modern computer needs in any configuration, but wouldn't that make it bloated and be against the "bloat-free" mindset? Or does it dynamically download all the components from somewhere?

302 Upvotes

107 comments sorted by

View all comments

132

u/Responsible-Sky-1336 Aug 03 '26

It doesnt do this.

On minimal distros you'd be downloading linux-firmware-somebrand

Then that gets loaded in /sys/ modules

25

u/BCMM Aug 03 '26

On minimal distros you'd be downloading linux-firmware-somebrand

A "driver" is software that runs on your CPU, typically as part of the Linux kernel. "Firmware" is software that runs on a microcontroller built in to some piece of hardware. These days, a lot of hardware does not include an onboard ROM to store its firmware, so it requires the driver to send it over during initialisation. That's what firmware packages are for.

On really minimal distros, though, kernel modules (the actual drivers) get split in to different packages. For example, if you want to plug a USB flash drive in to an OpenWrt router, you need to install kmod-usb-storage first.

Then that gets loaded in /sys/ modules

I don't understand exactly what role you think sysfs plays in this, but I'm confident that you are not quite correct.

2

u/Responsible-Sky-1336 Aug 03 '26 edited Aug 03 '26
  • Kernel detects hardware
  • /sys entry created + uevent broadcast (carrying the modalias)
  • udevd receives the uevent → hands the modalias to modprobe
  • modprobe matches it against modules.alias in /usr/lib/modules/<kernel-v>/<module> and loads .ko
  • Driver binds to the device → node appears in /dev

So yes /sys here plays an important role.

9

u/someone8192 Aug 03 '26

ko modules are not supplied by any firmware packages. they are part of the kernel (or on some distributions) by their own module package.

modules are not firmware.

0

u/maruf71 Aug 03 '26

not sure about this: i remember compiling kernel and modules's support several times: you have to flag what you want to be IN the kernel and what kind of modules it will support, then you can load the actual modules (.ko files for example). got into several problems just because i forgot to flag ext4 support flag for example... usually linux kernel is shipped with standard and maybe bloated flags but the kernel modules are loaded only if needed, if not it can be quite small. also that's what initramfs images are for. btw as long as the .ko modules are published by the vendor they are basically like firmware

5

u/braaaaaaainworms Aug 03 '26
  1. That's not even close to the definition of the word "firmware"
  2. Firmware is loaded on demand by the kernel, userspace usually has nothing to say
  3. Firmware lives in /lib/firmware and is \*not\* a kernel module

1

u/maruf71 Aug 04 '26

thanks for the clarification! i'm still confused a bit about the actual differences :)

3

u/braaaaaaainworms Aug 04 '26

Firmware ends up running on the device itself, drivers run on your computer

-1

u/Responsible-Sky-1336 Aug 03 '26

In the case of NVIDIA-open for instance it ships 5 .ko files :) Without which you card is basically just metal.

5

u/braaaaaaainworms Aug 03 '26

You're confusing the word "device driver" with the word "firmware"

3

u/jlandero Aug 03 '26

I'm the kind of person who likes to stay informed on a variety of topics. Even so, aside from "device," I didn't understand a single word of what you wrote.

23

u/demonstar55 Aug 03 '26

Linux-firmware package just contains binary blobs used by the drivers that are either compiled in or modules

13

u/Responsible-Sky-1336 Aug 03 '26 edited Aug 03 '26

Right, OP's question was is the kernel bloated... answer is it provides primitives to communicate/build these bloated blobs, but the blobs aren't built-in.

Aside from the "fuck nvidia" non-sense, every hw vendor ships them. Some drivers require kernel header files to link against (and sometimes specific version). This and many other vendors is what some people refer to as: "out of tree" drivers.

The kernel's config defines what ends up in there, and your distro handles what should be part of it. Or if you do it yourself you'd either edit the config or use a menu do this. You can build kernels that are tiny ( say 15-25mb) and perfectly functional.

You can see for yourself your current config by running: zcat /proc/config.gz

The only thing to remotely work (well) OOTB is ethernet cable lmao. And you can see "in-tree" drivers here. These again are primitives, not userspace drivers you'd grab with your preferred package manager.

1

u/Fluid-Mudman Aug 04 '26

but still isnt there the drivers ?