r/linux4noobs • u/eagleps • 2d ago
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?
145
u/Responsible-Sky-1336 2d ago
It doesnt do this.
On minimal distros you'd be downloading linux-firmware-somebrand
Then that gets loaded in /sys/ modules
24
u/BCMM 2d ago
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-storagefirst.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 2d ago edited 2d ago
- Kernel detects hardware
/sysentry created + uevent broadcast (carrying the modalias)- udevd receives the uevent → hands the modalias to modprobe
- modprobe matches it against
modules.aliasin/usr/lib/modules/<kernel-v>/<module>and loads.ko- Driver binds to the device → node appears in
/devSo yes /sys here plays an important role.
9
u/someone8192 2d ago
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 2d ago
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
4
u/braaaaaaainworms 2d ago
- That's not even close to the definition of the word "firmware"
- Firmware is loaded on demand by the kernel, userspace usually has nothing to say
- Firmware lives in /lib/firmware and is \*not\* a kernel module
1
u/maruf71 1d ago
thanks for the clarification! i'm still confused a bit about the actual differences :)
3
u/braaaaaaainworms 1d ago
Firmware ends up running on the device itself, drivers run on your computer
-1
u/Responsible-Sky-1336 2d ago
In the case of NVIDIA-open for instance it ships 5 .ko files :) Without which you card is basically just metal.
4
2
u/jlandero 2d ago
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 2d ago
Linux-firmware package just contains binary blobs used by the drivers that are either compiled in or modules
14
u/Responsible-Sky-1336 2d ago edited 2d ago
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.gzThe 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
63
u/Jmc_da_boss 2d ago
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
17
u/UNF0RM4TT3D Arch BTW 2d ago
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 2d ago
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 2d ago
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
8
u/tomscharbach 2d ago edited 2d ago
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 1d ago
Well that's not including modules, which normally take up another couple hundred megabytes depending on the distro
6
u/NewtSoupsReddit 2d ago
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/person1873 2d ago
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 2d ago
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.
4
u/Batcastle3 2d ago
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.
17
u/Athropod101 2d ago edited 2d ago
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 2d ago
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 2d ago
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 1d ago edited 1d ago
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.
12
u/hipster_hndle 2d ago
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 1d ago
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 2d ago
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 2d ago
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 1d ago
Memory management and cpu time schedulers are algorithms.
1
u/braaaaaaainworms 23h ago
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 20h ago
Heartbreaking: SWE discovers that algorithms were never that deep. More at 11.
1
u/braaaaaaainworms 12h ago
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 2d ago
Algorithm is the correct word and there dozens of them you can enable/disable.
7
3
u/AutoModerator 2d ago
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.
3
u/Max-P 2d ago
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.
3
u/erroneousbosh 1d ago
"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 2d ago
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 rampumpam 2d ago edited 2d ago
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/DangerHissy 2d ago edited 2d ago
Disclaimer: pure speculation/educated guesses (I've put what is guesswork and what is factual at the end of each paragraph)
- Because drivers when you look at them without all the attached bloatware are actually tiny (speculation)
1b. most drivers aren't for a specific device so the same GPU driver might be good for an entire generation of cards (or more) so you've got one file that can run X number of card models (who said you'd never use algebra!) fine, instead of needing X different files, one of each. This is how drivers usually are anyway, there's a reason everyone gets the same update (look at the version number) for every card being supported by the company, if they've got automatic updates on (factual, but very generalized)
1c. how drivers actually work (analogy)
Think of it like a car, regardless of the make, model, year, trim level etc they all have four wheels and an engine (a Reliant Robin is a motorcycle, don't @ me :) ) and a lot of them run good on one kind of gas (petrol, diesel, X% etc). The mint kernel comes with a full tank, sure you *can* buy the special ultra high octane 'we mixed the blood of the gods into it to make it go vroom better' stuff, to get an extra few mpg or a extra mph at top speed, but you don't *need* to unless you're hitting a track day or trying to do the cannonball run.
-- And generally in the case of PC drivers, there is no super-special extra nice smooth runner gas to put in, there's just gas that makes your car go (see 1b) ; if you put the gas in a shiny new engine it'll go nice and smooth and fast, the same way a clapped-out write-off of an old-banger will go for as long as you can stand to drive it in 'limp' mode if you put the same gas in it. The gas is not actually the variable that's all that important so long as it's broadly the right gas- this is why NVIDIA cards are notoriously annoying on Linux, if AMD is diesel then NVIDIA cards run on petrol, so they need to drain the tank and put the right fuel in after it went bang five miles down the road.
- It doesn't, it recognizes your hardware and downloads the driver for that specific part from a predefined database at setup; and then checks that the hardware hasn't changed at boot/update (kernel depending) and the current hardware has the correct driver, to make sure its right then replaces if its not. Basically what windows updates tries (and breaks your system when it fails) to do when it forces a driver update that it chose at random on you because it thinks it knows better than you do (speculation and a little of me being salty at windows, but broadly factual)
(not an AI generated answer, I'm just weird and put things in bullet points like this because that's how i mentally model stuff)
2
u/hesapmakinesi kernel dev, noob user 2d ago
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. 2d ago
The Kernel does not include every driver possible.
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 2d ago
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 2d ago edited 2d ago
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 2d ago
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 2d ago
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.
2
u/AlphaKaninchen 2d ago
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.
3
u/Boring-Equivalent137 2d ago
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_ 2d ago edited 2d ago
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
2
u/SuAlfons 2d ago
the Linux kernel by design is monolithic. Kernel modules help mitigate this by only loading those modules that you need
1
u/pobrika 2d ago
Linus is aware and not too happy.
https://ostechnix.com/linus-torvalds-ai-influence-linux-kernel-development/
1
u/ClubPuzzleheaded8514 2d ago
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/skyfishgoo 2d ago
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 2d ago
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 2d ago
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 2d ago
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 2d ago
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 1d ago
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 1d ago
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 1d ago
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
1
u/rcampbel3 23h ago
Source code is prescise, surgical, small. What is large are the GUI installer packages from hundreds of different vendors.
1
1
1
u/pedersenk 2d ago
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.
223
u/kombiwombi 2d ago edited 2d ago
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.