Linux – scripted configuring of a linux kernel

kernellinux

Given a list of kernel features, I want to create a minimal linux configuration supporting all given features (and the corresponding dependencies) but nothing else.

Is there a way to create a allnoconfig and a tool to enable features one by one?

(I could edit the .config file but this would not get dependencies right. I could use make *config, but as far as I know those work only interactive or create some default config.)

Best Answer

If you need to do it non-interactively, you might be able to use make oldconfig or make olddefconfig. make *config will fix the dependencies and those aren't as verbose as, say menuconfig. (Otherwise menuconfig is perfectly fine for enabling features one by one, it even includes the help texts!)

make oldconfig will ask for any 'new' configuration options, so you would need to insert comments like this for any disabled options if you want to work non-interactively:

# CONFIG_KERNEL_GZIP is not set

make olddefconfig on the other hand doesn't seem to ask, but uses a default value. There's also silentoldconfig, but it also asks in some cases, so it's not that silent.

from make help:

oldconfig       - Update current config utilising a provided .config as base
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
olddefconfig    - Same as silentoldconfig but sets new symbols to their default value

Disclaimer: I only tried the trivial test of removing the options for some libraries I know were needed. They were added back by olddefconfig and oldconfig. I don't know how this applies to doing a larger configuration.

In any case, I suppose you already considered using make localmodconfig or something like that before starting this? I haven't tried making a minimal config in years, but I seem to remember there were some rather non-obvious ways to create totally unusable kernels. :)

Related Question