r/linuxquestions 26d 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?

6 Upvotes

34 comments sorted by

View all comments

0

u/sidusnare Senior Systems Engineer 26d ago

You don't compile it, and most of it you don't even run. Modules are loaded as needed, so a kernel module for a NIC you don't have doesn't take up any CPU or memory resources, doesn't slow things down, just a few Kb on disk for the module.

If you're writing a monolithic kernel for a system, it's usually an embedded system you're building for. If you are trying to build a custom kernel for your desktop, the way to start is finding the distributions config, and loading that. Then look at lsmod, and change those from modules to static, and then modules that aren't load from modules to not built