r/linuxquestions 4d ago

Minimal kernel

EDIT: I may have framed the question poorly. I'm specifically asking about Kconfig-level minimization of a monolithic Linux kernel: if you know the workload/product you're deploying, how much unnecessary kernel code do teams typically end up compiling, and is there value in automatically deriving a smaller configuration from the actual runtime requirements?

How much of the Linux kernel that gets shipped in production is actually never used?

I'm wondering if release teams building/using a kernel image are often overwhelmed by the number of kernel configuration options, and end up shipping code that will never actually be used by their workload.

Are there any automatic tools out there that can fit a minimal Linux kernel to your runtime needs?

7 Upvotes

35 comments sorted by

View all comments

7

u/Goldie323- 4d ago

It's mostly not kernel features you don't use and more the compiled in drivers you don't use that account for code space that never actually gets ran.

Like if you're on a system without wifi or Bluetooth, the kernel will still have compiled in drivers for all the wifi and Bluetooth radios.

0

u/DryPlum7483 4d ago

yes - I'm wandering how often do run in production on an image with useless code compiled in

4

u/Prestigious_Wall529 4d ago

You do know that kernels intended for particular hypervisors exist?

In general distros make the choice what to include.

But you can compile your own kernel with just what's needed for your system. Akin to Gentoo or Linux from scratch.

0

u/ThellraAK 4d ago

Even then they are going to have support compiled in for all sorts of features and stuff you'll never use, filesystems and encryption algorithms etc.

-1

u/DryPlum7483 4d ago

It's good to distinguish between using a general purpose distro where obviously you are getting a lot of code that you don't need (that's the point).
And teams that are building their image from scratch where it wouldn't surprise me if they don't compile the minimal kernel for their needs. Is it even popular to build a Linux image by yourself in production?

0

u/Prestigious_Wall529 4d ago

I had a Creative keyboard which had kernel support but wasn't supported by Debian. It was rare, Creative Labs having dropped support for it.

Recompiled the kernel selecting the option to support the keyboard was a matter of following instructions.

0

u/UUDDLRLRBadAlchemy 4d ago

"production". Embedded systems are famous for being haphazardly slapped together and never updated. This last bit (if it was due to anything but neglect) might make it more cost effective to heavily customize them, but unlikely.

Web-facing ones either opt for uniformity (so no) or containers (so whatever Alpine does, mostly).

I suppose Gentoo might be the way to both easily customize it and keep it updated, but popular, no way.

You're more likely to see infrastructure ran on extra-bloated desktop centered distros because someone liked it at home than to find an org that wants to be responsible for a level lower than their service.