Modifying Linux kernel configuration options the easy way

November 4, 2005

Modifying a Linux kernel configuration option can be an annoying experience, as you poke around the menus of 'make menuconfig' trying to find where the configuration option you want to change is hiding. Fortunately there's a less well known but much easier way.

The kernel build process stores configuration settings in the file .config in the root of the kernel source tree. However, it generates other things from the file (and some options are interdependent), so you can't just edit the file and go; you need to resynchronize the build system with the .config.

So the easy way to modify an existing configuration is the following:

  1. Find out what the CONFIG_ variable you want to change is. Many of these have obvious names, like CONFIG_SMP.
  2. Edit .config to delete any mention of the option, even if this is in a comment. (Comments are significant in .config files.)
  3. Run 'make oldconfig', which will stop to ask you about the missing options at appropriate moments.
  4. Build.

Finding the right CONFIG_ variable is a bit tricky. I will just say that they are all specified in Kconfig files in various source directories (for example, net/Kconfig), which is also where you find all of the help text. (A few Kconfig files are called things like fs/Kconfig.binfmt.)

'make oldconfig' is also what you use if you're migrating a .config from one Linux kernel version to another, since it will prompt you about any new configuration options (including new drivers). In fact, any time you change or shuffle .configs around, you want to do 'make oldconfig'; it is the easiest way of getting the kernel build system synchronized with the .config.

PS: remember to save your .config file before you do a 'make mrproper' to clean out kernel source trees; it's one of the files that a full cleaning deletes.

PPS: many distributions ship kernel source with their .config files stored somewhere; for example, Red Hat (including Fedora Core) puts them in configs/*. They make good starting .configs, saving you the tedium of 'make menuconfig' from scratch.

Written on 04 November 2005.
« Fun with upgrading our backup server
Minimizing object churn to optimize Python code »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Nov 4 01:55:03 2005
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.