Really small kernel

Ralf Mardorf silver.bullet at zoho.com
Tue Oct 29 07:25:13 UTC 2019


Hi,

a starting point is localmodconfig.

"B. Generated configuration
Tip: Plug in all devices that you expect to use on the system if using
this method.

Since kernel 2.6.32, the localmodconfig command will create a .config
file for the custom kernel by disabling any and all options not
currently in use by the running kernel at the time. In other words, it
will only enable the options currently being used.

While this minimalist approach will result in a highly streamlined and
efficient configuration tailored specifically for your system, there
are drawbacks, such as the potential inability of the kernel to support
newer hardware, peripherals, or other features. Note: Again, ensure
that all devices you expect to use have been connected to (and detected
by) your system before running the following command

$ make localmodconfig" -
https://wiki.archlinux.org/index.php/Kernel/Traditional_compilation#B._Generated_configuration

You probably want to fine tune the generated config. Do you want a slim
kernel that is still compatible with Ubuntu defaults? If yes, you
probably want to care that apparmor is enabled, if not you probably
want to disable audit, which results in apparmor disabled, too. There
might be other important config settings, too and perhaps even relevant
Ubuntu specific patches.

Assuming the kernel should just work with Ubuntu installs, but needs
not to support something such as apparmor (e.g. keep "snappy" in mind
before you decide if it's needed or not), you still should think about
to add one or the other hardware support manually to the config.

In short, it is possible to build very slim kernels, but you need to
read up on what is required for the infrastructure of the distro you
are using, if it still should be full compatible, OTOH you might not
need compatibility to the full infrastructure of the distro.

You also won't run "make olddefconfig" if you upgrade your kernel,
                            ^^^
using the tailored config, instead you perhaps could run
"make oldconfig" and to reply to each question manually.
        ^^
Even running "make oldconfig" might be suboptimal, since it still would
add some new features with upstream defaults.

To stay close to the original Ubuntu kernel configs, you could copy
such a config and run "make menuconfig", to disable everything you
don't need manually, but to stay with defaults, such as maybe some
selected Hz, PREEMPT or mitigation or what ever else settings. Note
Ubuntu provides different kernels by official repositories, the most
likely default all to the same mitigation settings, all most likely
support apparmor, but some might come with different Hz and PREEMPT
settings. The Ubuntu lowlatency kernel for example automatically boots
with "threadirqs".

Also take a look at
https://www.kernel.org/doc/html/latest/kbuild/kconfig.html and other
relevant kernel.org information.

You have got to do some homework, I doubt somebody will do it for you.

Regards,
Ralf





More information about the ubuntu-users mailing list