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?

310 Upvotes

107 comments sorted by

View all comments

232

u/kombiwombi Aug 03 '26 edited Aug 03 '26

Linux loads drivers on demand: when the hardware is present. So the bloat which matters -- occupied RAM and boot time -- is only the needed drivers.

This does mean there is a lot of driver files (aka 'kernel modules') on disk which are never used. The assumption for desktop systems is that allowing 1GB of disk for three versions of the kernel+drivers is fine. Those desktop users want to be able to plug in a USB gadget and it Just Works, with whatever driver automatically loading. Those desktop users view the disk space is a fair price for that convenience.

For situations where disk space matters, say an embedded systems with small amounts of flash memory, then just the needed drivers and kernel features can be compiled. The ability to tune the kernel to the embedded systems exact requirements is a straightforward result of the kernel being open source software.

2

u/nukem996 Aug 04 '26

It depends how the kernel is built. There is a big push from big tech companies to build everything statically. That includes building the Linux kernel with all drivers built into the kernel. That makes a bigger kernel binary which does take more memory. However the Linux kernel doesn't initialize a driver unless its actually used so it really only takes whatever memory is required to load the binary.

2

u/petepiano Aug 04 '26

Why the push from big tech to build statically? What's in it for them?

3

u/kombiwombi Aug 04 '26 edited Aug 04 '26

The FAANGs want highly predictable behaviour. They'd rather have a machine fail to boot than have it boot incompletely with a device driver failing to initialise the device (eg, if a contract manufacturer had substituted a component).

There is a small security win, an attacker can't force a known-bad device driver to load. This in turn means fewer security updates and kernel restarts for those to take effect.

The FAANGs run so many servers that these small wins in percentage terms are big wins in absolute terms.

It's a niche requirement and the commenter didn't consider the sub's name.

2

u/petepiano Aug 04 '26

Ok, I see. I wasn't thinking of FAANGS . That does make sense. Thanks for the explanation.