Skip to content

Instantly share code, notes, and snippets.

@RenatoExpert
Created October 30, 2022 00:23
Show Gist options
  • Save RenatoExpert/99db4b2b3b00dedc46ba273d7745e4bc to your computer and use it in GitHub Desktop.
Save RenatoExpert/99db4b2b3b00dedc46ba273d7745e4bc to your computer and use it in GitHub Desktop.

Configure a custom kernel to be compiled

How settings are storaged

The configuration is just a ´.config´ text file inside source directory. Each line mention an option like CONFIG_ARCH_USE_MEMTEST=y. Every driver can be marked to be compiled into the kernel monolith (DRIVER=y), or as module(DRIVER=m), or as not be compiled(DRIVER=n).

How to get or create a .config

  • You can copy from your distro's config. Its location varies, but is usually something like /boot/config-3.0.7 (need to rename) or /usr/src/linux/.config.
  • Another option is to generate a brand new using make alldefconfig (create a .config with default modules) or make tinyconfig (a very tiny kernel).

How to change an existing .config

  • You can run make localmodconfig to update current config disabling modules not loaded, to disable modules not in use.
  • You can use an assistant, just type (from the easiest to hardest): make xconfig, make gconfig, make menuconfig, make nconfig or make config.

What I recommend for begginners

  • Make a directory to save your different kernel config flavors, then backup config files that you enjoyed. It may be useful to re-use them sometimes.
  • Maintain more than one kernel on boot. In case your main kernel crash, just boot with another one.
  • Its good to have a bootable media to save your life also.
  • Doing make alldefconfig; make localmodconfig is a good combination in case you don't have a old config to begin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment