Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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 localmodconfig.


1.Located in scripts/kconfig/

share|improve this answer
  1. 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.

  2. 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.

  3. 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.

  4. 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.