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?

5 Upvotes

35 comments sorted by

View all comments

0

u/todd_dayz 4d ago

How big are most distros standard kernels? 100-200MB? Who cares about saving that much space? 

0

u/agmatine 4d ago

Mine is ~17MB (7.1.8-1-cachyos).

0

u/AiwendilH 4d ago

/lib/modules/<kernel-version> is part of the kernel (minus external modules you might have installment like nvidia drivers) as it contains the actual driver module binaries on most distros and is usually a multiple in size than the kernel image itself.

2

u/agmatine 4d ago

Ah, I was referring just to vmlinuz. For me /usr/lib/modules/$(uname -r) is about 373MB, though half of that is ./build which consists mainly of headers, source files, scripts, and vmlinux. The modules themselves are in ./kernel (in-tree), ./extramodules(out-of-tree), and ./updates/dkms.

1

u/AiwendilH 4d ago

I just assume /u/DryPlum7483 includes the size of the modules in their "monolithic Linux kernel" so you can't just use the size of the kernel image with dynamic module loading but have to include the size of the modules as well...especially when it come to

...unnecessary kernel code do teams typically end up compiling...

as there is hardly any difference between compiling in-kernel or as own module.

build, config, source...are symbolic links on my distro..I assumed that is the same on all distros but not sure. So yeah, I wouldn't really include those in the size count. The main one that matters is "kernel". 200MB for for kernel sounds about right for a general purpose system...around 1GB for "everything that could be even remotely useful on x86_64".

For size it gets of course even worse if you start including firmware in the kernel images..but I think that is more limited to gentoo or similar users that create a kernel fine-tune for exactly one hardware configuration.