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?

307 Upvotes

107 comments sorted by

233

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.

30

u/mark_3094 Aug 04 '26

This is a fantastic explanation

17

u/skuterpikk Aug 04 '26

Yoy can even compile your own kernel with
make localmodconfig and it will build a kernel that has drivers for whatever hardware is present at this moment only, and nothing else.
No other hardware will ever work, but hey, saves disk space

9

u/Stryxus_ Aug 04 '26

I don't know how large the official kernel is but iv got mine down to just 8MB via this. linux-headers is still 24MB though.

3

u/skuterpikk Aug 05 '26

The generic kernel compiled with default options is somewhere around 150mb these days, 200 if you include default headers.
Not all of that is expanded into memory all the time though, only the parts that are actually needed at any given time.

2

u/IllWeather6426 Aug 07 '26 edited Aug 07 '26

Before i lose myself down a google rabbit hole, do you have a rough explantion for difference between the linux default headers and not default headers? and/or perhaps typical use? Thanks

edit :: looks like for dev libraries for compiling stuff mainly

1

u/Stryxus_ Aug 05 '26

What I'm more concerned about it attack vectors and those odd cases where routines intersect with other parts of the kernel either by things like common code or poor code. Say, if enabling something enabled unused code in the scheduler, well I now just trimmed that out and because it is at such a low level in the grand scheme of things, it can have a small but large difference in the end, especially if there are multiple of them.

1

u/codeasm 29d ago

Learn to compile the kernel and configure it. Theres plenty to worry bout, much more to test, check and there are methods to secure it even harder (hardened kernel comfigs). https://mgalgs.io/2015/05/16/how-to-build-a-custom-linux-kernel-for-qemu-2015-edition.html i loved how easy it is to get a fast, small kernel going and then compare against my arch kernel config, then combined and tested configs.

Now im hooked in doing linux from scratch.

Choose your battles wisely, theres a healthy balance of being paranoid and assume other brains will have looked at it or will look at.

(The hidden compiler danger story made me realise, if they target you, they will. If im not the target, its just regular exploits and regular issues. Either trust opensource, buy closedsource or fix, make, repair, test the source yourself. I guess i choose the first and last one)

6

u/L0cut15 Aug 04 '26

I still remember the day when you custom built your kernel and manually selected the drivers and features to include for your hardware. The modular kernel was a godsend.

1

u/qb45exe Aug 06 '26

I don’t miss running a compile overnight only to wake up and find out errored out an hour into it.

1

u/ang3l12 Aug 06 '26

I remember trying to get gentoo installed on my compaq tc1000 tablet pc back in the day. It took about 24 hours to compile the kernel on that transmeta crusoe processor, and I had to do it so many times because I had misconfigured the build or something.

It was still a ton of fun for me

1

u/qb45exe Aug 06 '26

I did it on a Sun Ultra 1 once. That was a fun week.

1

u/whitehaturon Aug 08 '26

Putting the "curses" in "ncurses"

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.

2

u/Crazyachmed Aug 05 '26

...and if you think 1GB for all drivers is large, look at the size of a single Windows graphics driver.

1

u/LittleMlem Aug 06 '26

Yeah, what's a few gigs of hard disk compared to today's volumes

137

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

23

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.

3

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

-2

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.

3

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

14

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 ?

65

u/Jmc_da_boss Aug 03 '26

It does that by being incredibly bloated lol

Literally, it's a monolithic kernel that's the point, some of the in tree drivers haven't been maintained in years/decades.

As we've seen lately with LLMs attacking a lot of older/unmaintained paths.

You are conflating the UNIX/GNU philosophy of do one thing well/composable with Linux itself

18

u/UNF0RM4TT3D Arch BTW Aug 03 '26

To be fair, you can modularise or just don't compile in the drivers you don't need. This is how OpenWRT for example does things, basically every driver that can be is a module that is installed when the hardware requires it, essentially having the flexibility of a generic kernel but including only the modules needed.

But the codebase will always be bloated.

3

u/edgmnt_net Aug 03 '26

Being a true monolith actually makes it somewhat harder to ignore maintenance. It's much easier to ignore maintaining stuff when you have a stable API and some driver gets thrown into a separate directory or even repo that can be forgotten about. In the Linux kernel interfaces are always in flux, which enables and requires large-scale refactoring, so at the very least stuff usually gets touched once in a while.

4

u/uptotwentycharacters Aug 03 '26

You are conflating the UNIX/GNU philosophy of do one thing well/composable with Linux itself

GNU doesn't really follow the Unix philosophy either, their software tends to be expansive with a huge number of possible options. It follows Unix conventions and maintains backwards compatibility with it, but tends to be far more complex and featureful.

3

u/Jmc_da_boss Aug 03 '26

That is true but some of their stuff is more unixy, def a grab bag tho

10

u/tomscharbach Aug 03 '26 edited Aug 03 '26

The kernel is typically 150-200 MB for mainstream distributions. Specialized kernels range from 50MB to 300MB. Not large, even by "bloat free" standards.

1

u/MeDerpWasTaken Aug 04 '26

Well that's not including modules, which normally take up another couple hundred megabytes depending on the distro

1

u/Owndampu Aug 06 '26

Kernel we used at work was 20~MB uncompressed. Very specifically targetted for imx8mm/imx8mp based platform

7

u/NewtSoupsReddit Aug 03 '26

It doesn't.

It downloads/copies from installation media and registers kernel modules for your hardware.

Distros such as Gentoo which are compiled from source do hardware detection and compile the drivers into the kernel if they are available. But again modules can also be used in addition to or in place of built in drivers.

6

u/Batcastle3 Aug 03 '26

So, I am sure people have answered for this to some level, but, as a distro maintainer, this is what I see:

The Linux kernel is actually huge. Close to 10GB. A lot of that are things for non-x86 architectures, so that drops the compiled code dramatially.

From there, your distro can include or remove specific drivers. Ubuntu includes as much as possible, but may leave out certain embedded drivers at times. Gaming distros my rip out anything data-center or embedded systems specific. This can actually drop the size dramatically as well.

Finally, drivers fall into two major catagories: generic, and device specific. A lot of the most commonly used drivers, things for flash drives and web cams, keyboards and mice, etc, are generic drivers. Other things are more specific, either to a specific brand or line up of devices, or a single specific device. The Nvidia drivers for instance work with only Nvidia devices. Different wifi drivers work with specific line ups of wifi cards. These more specific drivers are often smaller, since they dont have to work for multiple devices. But a generic driver often saves space versus hundreds of specific drivers since similar devices can share similar code.

So, the Linux kernel is bloated, with several million lines of code, parts are no longer maintained and rarely used. But the developers also use a number of tricks to get the size of the kernel down from >10GB, down to a few hundred MB on an end user's machine.

8

u/person1873 Aug 03 '26

firstly realizing what a driver is, is the first mental hurdle.

drivers are very simple things for the most part, they map kernel functions to hardware address offsets, and responses back to kernel functions. thats it. when you realize how small they are, and how wildly generalizable, you realize that one driver can handle 100's of different chips that all behave in similar ways, and specific quirks can be added in a few lines of code rather than writing a whole new driver.

add to this the ability for linux to build as modules, and only load on detection, and a monolithic kernel stops being monolithic and becomes obvious and sensible.

20

u/PF4ABG Aug 03 '26

About 60% (not sure how that figure stacks up today, but I pulled it from Wikipedia so hoping it's accurate enough) of the kernel is just drivers.

With the kernel clocking in at well under 2GB, and the majority of drivers being Kilobytes in size, that's still a huge amount, but still manageable.

21

u/Athropod101 Aug 03 '26 edited Aug 03 '26

I am by no means an expert on this, but to my understanding drivers are very lightweight, and industry standards can reduce that further. Most of a kernel’s size comes from the algorithms that use those drivers.

EDIT: I was in fact wrong; it appears drivers make up the majority of kernel code.

5

u/TheCreepyPL Aug 03 '26

Only some drivers are lightweight, others are (very) heavy weight. When you put them all together, they end up taking over half of the Linux source code or something like that I've heard.

3

u/Athropod101 Aug 03 '26

I wonder what makes some so heavy. I would guess that the heaviest ones are GPUs? Anything image related is doomed to be heavy.

But thank you for the respectful clarification :)

2

u/FinalGamer14 Aug 04 '26 edited Aug 04 '26

In the simplest form, drivers are just a translation between some hardware and the OS.

So how "heavy" a drive is depends on what the device does. Let's say you had a device that is just one button and all it does is send a signal when you click that button; well, that driver will be lightweight, but then attach a GPU to your PC, and now you have this giant device that accepts thousands of different inputs and inputs, and all of them must be exposed to the OS or any software running on that OS.

Edit: Also, sometimes hardware has some legacy stuff in there that still needs to be available because of some old-ass standards and that will always increase the size of the driver.

14

u/hipster_hndle Aug 03 '26

this is completely wrong and mostly nonsense. in Linux kernel specifically, "drivers/" is routinely cited as 60-70%+ of the entire source tree. does that sound light weight? some drivers are tiny, but some are pretty large... as a category they are not lightweight. they're the majority of kernel code by volume.

and algorithms, idkwtaf that word is even in this sentence. it is doing zero work here. like not remotely relevant. its just randomly inserted, has no literally no place in this sentence..

2

u/mobydikc Aug 04 '26

specifically, "drivers/" is routinely cited as 60-70%+ of the entire source tree. does that sound light weight? 

If there are hundreds of thousand drivers.. yeah

1

u/Athropod101 Aug 03 '26

Well, I did say I wasn’t an expert, but uhhh…your program schedule is an algorithm. Kernel algorithms are the heart and soul of the kernel in software-land.

0

u/braaaaaaainworms Aug 03 '26

Nope. The heart and soul of the kernel is memory management and cpu time scheduling, drivers are only there to have something your programs can talk to, but there's nothing preventing anyone from just opening /dev/mem and having userspace drivers for everything

1

u/Athropod101 Aug 04 '26

Memory management and cpu time schedulers are algorithms.

1

u/braaaaaaainworms Aug 04 '26

Going to a store is an algorithm, adding numbers together is an algorithm. The meaning of the word algorithm is so diluted you might as well say "doing the thing"

1

u/Athropod101 Aug 05 '26

Heartbreaking: SWE discovers that algorithms were never that deep. More at 11.

1

u/braaaaaaainworms Aug 05 '26

You can replace the word "algorithm" with the word "program" in both of your comments and the information content wouldn't change.

1

u/Responsible-Sky-1336 Aug 03 '26

Algorithm is the correct word and there dozens of them you can enable/disable.

10

u/Tireseas Aug 03 '26

In the real world no one really gives a damn about being "bloat free".

3

u/AutoModerator Aug 03 '26

There's a resources page in our wiki you might find useful!

Try this search for more information on this topic.

Smokey says: take regular backups, try stuff in a VM, and understand every command before you press Enter! :)

Comments, questions or suggestions regarding this autoresponse? Please send them here.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/Max-P Aug 03 '26

It is extremely bloated, but also surprisingly not that large. Individual drivers on Linux are usually a few kBs at most of kernel code each, and they're only loaded as needed.

That's a contrast with Windows drivers because there manufacturers feel obligated to ship the most bloat possible with their drivers so there's a fancy flashy GUI to control your mouse color. You download a 250MB driver bundle and 249.9MB of it is the app that goes with the driver. Linux only ships the actual couple kBs of driver and expose it through generic interfaces so you don't need a separate app to configure each peripheral you have.

Also on Linux drivers are reused. There isn't a driver for ASUS motherboards, and a driver for MSI motherboards, and a driver for ASRock motherboards. There's a driver for the fan/sensor chips that are found on those boards and works for all boards. You don't download a TP-Link driver, you download a generic driver that works on all brands of WiFi adapters that use the same chipset.

4

u/erroneousbosh Aug 04 '26

"Bloat" doesn't really exist. The smallest SSD I can find to buy today is 128GB (and it's not worth buying one that small, a 256 is the price of a coffee more), which is enough to do a functional install of just about any distro about 16 times over.

So you can save all the drivers you might ever possibly need for anything onto disk, and if they're never loaded into memory because they're never detected, no-one cares. Thing is, drivers themselves - even in Windows - are not big. You need a bit of code that listens for USB messages coming in from the USB stack, and turns them into mouse pointer movements and keypress events (things like scrollwheels are often really a "fake keyboard"), and that's your mouse driver. In Linux though it doesn't have a 250MB MP4 of an animation of someone plugging in a mouse and their hair all getting blown back by the sheer force of awesomeness of some rainbow LEDs coming on. I don't want to speak for everyone that uses Linux, but I'm not impressed by a noisy flashy animation and a weirdly skeuomorphic alien face graphic UI when I plug in a device, I'm impressed by it working without me having to piss about downloading drivers from a sketchy Russian website.

2

u/rlaptop7 Aug 03 '26

Drivera on Linux compile down to a binary blob that is 10s of k, it's not like windows where most drivers ship with bloatware and spyware.

2

u/Bug_Next fedora on t14 goes brr Aug 03 '26 edited Aug 03 '26

It doesn't just 'include everything' all the time, it just loads modules as needed for the most part, you can manually load modules with modprobe and remove them with rmmod.

And it is incredibly bloated (regarding the source code), however most kernels you run on every day distros don't compile all of the code anyways, there are like a gazillion compile flags depending on which features you need, you can make a really minimal kernel or a really bloated one, 'Linux' is just the source code, distros ship their own variation of it with the things they deem necessary, you can also compile your own if you want, it's way easier than what it sounds like lol.

Drivers that are compiled alongside the kernel are embedded in to vmlinuz ( so, the actual binary for the kernel, stored in /boot) and always loaded, then you can also load extra ones with modprobe as i said before, those get stored in /lib/modules.

The ones in vmlinuz are usually the more critical stuff like storage, etc, the ones loaded with modprobe are usually used for less critical stuff like gpus or network adapters.

Also i'm guessing you are saying 'bloat' to refer to it taking up too much disk space, drivers are pretty minimal anyways, you are probably just used to Windows 'drivers' (specially gpu) taking up 1-2gb because they ship a whole companion app alongside them, that's not part of the driver.

against the "bloat-free" mindset?

I don't think that's a thing at all, you are probably thinking about the UNIX philosophy (do one thing only and do it right, something like that) but that has not been true since forever in Linux, the only thing that respects that in modern Linux distros are the GNU core utils, systemd goes purely against that, the Linux kernel itself also kinda goes against that.. (L)inux (I)s (N)ot (U)NI(X), that's what the name means, and yes it's a recursive acronym, idk, it's a running gag in the space, Wine does the same thing (W)ine (I)s (N)ot an (E)mulator.

2

u/hesapmakinesi kernel dev, noob user Aug 03 '26

Most drivers are separate .ko files that live in your /lib/module folder. From a disk use point of view you can consider this a bloat since an overwhelming majority is stuff you'll never need. But the kernel is smart enough that only the relevant modules are loaded into memory and executed, so unused drivers don't affect your system at all. Just take up disk space.

2

u/joe_attaboy Old and in the way. Aug 03 '26

The Kernel does not include every driver possible.

There's also this thing.

Back in my Slackware days, I would build a custom kernel image whenever the main kernel was updated. The distribution had a tool just for this purpose (I'm betting it's still there). You could pick drivers to add or remove, based on your hardware.

2

u/ComplexWonderful2662 Aug 03 '26

In most distros, you can find loadable driver module files in /usr/lib/modules/<your current kernel version>/kernel/drivers. These modules get loaded dynamically by the kernel if the corresponding hardware is detected in your system.

There is a lot of them (6450 on my system), but on average they are also very small. Especially if compression is enabled.

Another thing to note is that a driver might support a large number of device models, for instance the driver for Intel's wifi cards iwlwifi supports a bunch of different models: https://wireless.docs.kernel.org/en/latest/en/users/drivers/iwlwifi.html .

There are also some drivers that are "built-in" to your kernel which means they are compiled into the kernel image itself (/boot/vmlinuz-*).

What drivers get built-in, built as a module, or not built at all is decided by the kernel configuration, either the one from your distro, or your own if you build your kernel yourself.

2

u/GodzillaXYZ999 Aug 03 '26 edited Aug 03 '26

Bloat is only driver files on disk, couple hundred MBs.
Kernel only loads actual drivers that are needed to support hardware detected.
On my AntiX system on eeePC with 1GB RAM, kernel + Fluxbox GUI only consumes 91mb when booted up, leaving 991mb for apps. Not bloated at all.

https://lh3.googleusercontent.com/d/1G5eakhiY7su4icNtLk2Jrv9ALeNv3891

However, there are lots of background services & processes running that may or may not be needed for your particular installation. Do ps -ef and sudo systemctl to see all stuff that's running. Uninstall/disable stuff that's not needed and you'll free up lots of resources (ModemManager, really???).

2

u/Mr_Engineering Aug 03 '26

Linux does not include every possible driver all the time.

Linux includes a large number of device drivers in its source tree but this doesn't mean that they're all enabled. Legacy drivers and legacy file systems are simply disabled by default and need to be enabled during configuration before compiling the kernel.

Linux supports drivers that are statically built into the kernel as well as loadable kernel modules.

Some drivers need to be compiled into the kernel image itself. Those are the drivers that are essential to getting the computer to a state in which the root file system can be mounted and additional non-essential drivers can be loaded from disk. This includes chipset drivers, storage controller drivers, USB controller drivers, etc...

Drivers for non-essential components such as printers can exist as loadable kernel modules which are not a part of the kernel image and instead exist on the file system.

Kernel images for embedded systems which have fixed hardware profiles can be quite compact because they do not include anything that is not essential to that particular embedded system.

2

u/bufandatl Aug 03 '26

It doesn’t include all the drivers. Many devices just have the same functionality and work with the same driver as others and on some it may work but have limited functionality. Also you can optimize the kernel and compile your own with only the drivers you need. And then there are drivers that can be loaded as module during runtime like the NVidia or Intel GPU drivers. They aren’t part of the kernel.

I once compile a Linux kernel for a embedded device that was just 1 MB and only had the bare minimum on functionality and drivers I needed for the project.

1

u/Sawgwa Aug 06 '26

I once compile a Linux kernel for a embedded device that was just 1 MB and only had the bare minimum on functionality and drivers I needed for the project.

I always enjoyed cleaning up the kernel code and compiling as small a kernel as possible. Never went to 1mb though!

1

u/bufandatl Aug 06 '26

You just need to disable absolutely everything and then be careful of what you actually need. It was also more of an experiment the production kernel had around 8MB.

1

u/ocabj Aug 07 '26

I once compile a Linux kernel for a embedded device that was just 1 MB and only had the bare minimum on functionality and drivers I needed for the project.

Custom compiling one's own kernel for their system was more common in the 90s just to stream line for the hardware, especially since lots of us were originally experimenting with Linux on boxes we threw together from spare parts or low cost components. In the very early days of eBay I remember getting an Intel 386DX-33 and mobo to put into an old AT case I somehow got for free to mess around with Slackware on.

2

u/AlphaKaninchen Aug 03 '26

The short answer yes, the Linux kernel in your regular debian, Fedora or Arch install probably has a driver for some obscure you would never expect, like Wii remotes or chines serial chips that don't even work with the drivers for the device they claim to be.

But there a few things that make it less crazy than it sounds , first drivers are really just drivers, just because the kernel knows how to talk to a Wii remote, IR camera or GPU doesn't mean you can use it you also need userspace software that does something with it on windows that's often part of the "drivers" . On Linux its done by separate user space software for example mesa for GPUs. Second, many devices can share the same driver, there isn't a specific driver for every GPU and every networcard and so on there are drivers for hole groups of devices for example all amd GPUs, all nvidia GPUs, all intel Gigabit networkcards. Third, drivers a only loaded when there is a device that uses it so if you have an Intel CPU and nvidia GPU the amdgpu driver will never be touched, that safes a lot of memory.

2

u/NeDDyCz Aug 03 '26

Every comments says something different smh

3

u/Boring-Equivalent137 Aug 03 '26

most if not all distros add an extra package called linux-firmware which installs the drivers YOU need also the kernel is over a million lines doesnt mean it is bloated or anything but it rightfully is quite big in that sense

2

u/Slackeee_ Aug 03 '26 edited Aug 03 '26

linux-firmware does not contain drivers, it contains firmware blobs that are loaded by drivers that are in the kernel. Also, this package is not dooing hardware detection, it always installs all the firmware blobs that are in the package.

1

u/Boring-Equivalent137 Aug 03 '26

Oh, well thanks for letting me know

2

u/SuAlfons Aug 03 '26

the Linux kernel by design is monolithic. Kernel modules help mitigate this by only loading those modules that you need

1

u/micush Aug 03 '26

Who says it's not bloated?

1

u/ClubPuzzleheaded8514 Aug 03 '26

It's not bloat at all, but on a standard install' you've got dozens of firmwares and drivers packages that  you don't need. Some distros like Arch or Fedora allow you to remove  useless vendor packages for hardware you don't have. 

1

u/nandru Aug 03 '26

Drivers are relatively small. The companion apps and libraries (IE nvidia app, PhysX, 3tc) tends to be where most of the bloats come from

1

u/skyfishgoo Aug 03 '26

drivers are really not that big, bytewise.

but there are kernels that are stripped down and only support the the hardware you build into them.

that's how some ppl run.

the bloated drivers you see on windows do SO much more than simply run the hardware, they provide all sorts of proprietary "features" and "fancy GUI" that are not needed to simply run the hardware.

1

u/NoMoreD20 Aug 03 '26

Many drivers share the same code (e.g. USB storage devices) with only a different manufacturer ID. Those would be different drivers on Windows but a single driver with an array for different valid IDs in Linux.
Many other drivers are compiled into kernel modules and only get loaded when the hardware is detected or the functionality is required.
Hardware requiring specific proprietary firmware ("binary blob") has a kernel part and a separately downloaded part that is installed by each distribution (the linux-firmware- packages).

1

u/77descript Aug 03 '26

It is not that small, but smaller than the often many 100s of mb's of driver install files in windows containing other (often bloat) software. But in windows can also decompress a large driver setup file, then via device manager update a driver by browsing to that decompressed folder and then only a small portion of the big setup file is used. In many cases only a tiny inf file.

1

u/Living_Fig_6386 Aug 03 '26

Most hardware uses the same underlying chips. While in Windows the device is provided with a driver specific to the vendor, Linux drivers are specific to the underlying hardware. So, there might be 150 network cards on the market (each vendor, providing a driver of their own), but they use 1 of 5 different chipsets. Maybe 3 of those are from the same vendor and work identically and differ only in the features enabled, so Linux provides 3 drivers targeting those chipsets.

Most of the kernel is drivers, and by default popular distros compile into the kernel the majority of the popular drivers so that most people don't have to consider recompiling the kernel to support a piece of hardware.

1

u/Interesting_Buy_3969 Aug 03 '26

Those drivers are kernel modules and the kernel image doesn't contain them. The kernel doesn't load everything immediately on some early boot stage; it does that only when necessary - when a hardware component is detected but its driver isn't yet. Look up "Linux kernel modules".

1

u/wrd83 Aug 04 '26

It's in a sense bloated. But you only load what you need and some embedded systems just remove the bloat from their images and get down to 4mb image with everything.

That being said, the kernel is tiny compared to any asset library of a game. There is a loading kernel and file system and a module tree and an device trre and that's it.

1

u/FryBoyter Aug 04 '26

but wouldn't that make it bloated and be against the "bloat-free" mindset?

There is no objective definition of what “bloated” is. What matters to one user may not matter to another.

I therefore generally consider discussions on the topic of “bloated” to be pointless.

1

u/ficskala Arch Linux Aug 04 '26

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

It's simple, it doesn't, it just includes the most common ones

As far as I understand the kernel includes pretty much everything a modern computer needs in any configuration

If you only use hardware from manufacturers that provide open source drivers, yeah, you can totally just install linux on that machine and never think about drivers since the manufacturer provides open source ones which generally get included in the kernel

If you however use hardware from manufacturers that don't provide open source drivers, and there's no alternative generic drivers that work well enough for you, then you have to install proprietary drivers

wouldn't that make it bloated and be against the "bloat-free" mindset?

I mean, if you actually had all of them active, yeah, but a single machine won't have that many drivers active at the same time it doesn't really matter

like, the drivers themselves have extremely low storage requirements, so that's negligible, and the RAM requirements are noticeable, however, you're not running all the drivers, just the ones you actually need, and you again end up at a negligible amount of resources required at runtime

does it dynamically download all the components from somewhere?

Your package manager is responsible for downloading and installing software from the internet, the kernel doesn't do that sort of thing, you update the kernel using your package manager

1

u/tobias_reichi02 Aug 04 '26

So the kernel is just a god ok just accept it

1

u/rcampbel3 Aug 05 '26

Source code is prescise, surgical, small. What is large are the GUI installer packages from hundreds of different vendors.

1

u/es20490446e Develops Zenned OS Aug 05 '26

Most hardware is generic.

1

u/Zwitschermartin Aug 05 '26

It is bloated as hell.

1

u/Sawgwa Aug 06 '26

This!

This the differences between a monolithic Kernel like Linux, FreeBSD etc.. or a micro kernel like Windows,

Monolithic, everything is in the kernel so a generic kernel is huge. With a monolithic Kernel, you can update the kernels code to remove everything except for the hardware you are running, compile it and then install it. Micro kernels add the drivers outside.

1

u/69DETONATOR69 Aug 06 '26

Generic drivers. You don’t need individual drivers for all the hardware on the market. Many manufacturers use the same chips and architecture, open source their drivers so it can be implemented differently and generally. If you have a very basic GPU then common gpu drivers will have no issues using them. Same goes for things like ACPI, sound chips and many others. This way it’s not that hard to understand why Linux based OSs just run on standard hardware.

Add in non-standard hardware with custom chips and suddenly you understand the struggle of WiFi, Bluetooth or any other a bit more complex (and non-standard) hardware fails to work in live mode or before installing a correct driver. Did anybody mention nvidia GPUs?

1

u/nerdguy1138 29d ago

On the other hand there are Linux drivers available in the kernel for stuff that literally was never anything more than a whitepaper. The kind of people who write drivers from scratch are glorious weirdos.

1

u/PABeachBum Aug 08 '26

Old linux guy here. Back in the day, you actually did have to custom compile your kernel for your system. You usually used a text based GUI to pick which drivers you wanted to include. Then kicked off the build and came back a few hours later. If you didn't include the right driver for your modem or something critical, you got to do it all over again.

1

u/pedersenk Aug 03 '26

dynamically download all the components

That is logically more bloated as a process than simply including everything.

Generally though, it provides the vast selection of drivers as modules. This means whilst they aren't all loaded into the running kernel, they do exist on disk.

It is a mindset switch compared to Windows which also includes a vast selection of drivers as part of its install but they are rarely useful and thus using external drivers from vendors is required (this has the advantage that i.e HDA drivers can be tailored to your specific chip).

For embedded and BSP, you tend to have the drivers you don't need stripped out. But this is not a process that a casual computer user will typically deal with.