I would like to create a minimal kernel for a web server.
When you compile a kernel from source how do you get hardware info and then know what drivers need to be kept in the kernel so the rest can be removed?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You should know under some distros like Arch or Gentoo; there are specialized kernels available for virtualization. For example if you want to run Linux under Virtuozzo or VMware technologies.
Use the command
lspci -n and paste it's output to http://kmuto.jp/debian/hcl; that site gives you the kernel modules needed in general. Then go to kernel configuration (e.g.
menuconfig) and press / to search the options, find their locations and activate them.
There is a site named "kernel seeds" which makes a
.config file for generic kernel according to kernel version. It is good to compare the
.config for kernel options and modules you are not sure about.
Try to build your kernel on your own and use config script less; it is better if you want to have kernel option related to your hardware.
lsmodin there and see the list of loaded modules. these are the list of kernel options you need to either build in your kernel or add as module to your kernel and load at the boot time.
There is a helpful script shipped with more recent kernels,
streamline_config.pl1, which will assist you to create a
.config file containing only those modules necessary to your currently running kernel. The script has a commented "How to" with all of the necessary steps.
Another way to accomplish the same thing manually is to use
localmodconfig. After unpacking and preparing your downloaded kernel, plug in any external devices you are likely to need in your new, custom kernel so that the relevant modules are loaded.
You then start the compilation process with the
make localmodconfig command and your
.config file will be generated based upon only the currently loaded modules.
In both cases, it is paramount that you ensure that you have everything you need listed in
lsmod prior to compilation,or those modules will not be picked up for the build.
The first (several) times you do this, review the generated
.config file prior to compilation to check it has what you need.
The Arch Wiki has a page on compiling the traditional way and includes details on using