Kernel/IKCONFIG support

Configuration and usage of In-kernel Config (IKCONFIG) support for kernel beginners.

What is IKCONFIG
In-kernel .config support, also known as IKCONFIG, allows you to build a copy of the configuration the kernel was built with inside the kernel itself. This allows you to inspect the configuration of the kernel while it is running, without having to worry whether you've changed or cleaned the source directory after it was built.

Why is it important?

This can assist with debugging things like if a particular driver was compiled when the kernel was built, whether a networking option was enabled, or any other configuration option when you built the kernel, and is often asked for when looking for support on the forums or IRC channels.

Enabling IKCONFIG Support
Kernel .config support can be enabled either built in to the kernel, or as a module. If built in to the kernel, there will always be a file to read the configuration from. If preferred, it can be built as a module so that the configuration is only available when you have loaded the module.

Accessing IKCONFIG
If you built IKCONFIG support as a module, then before you can use it you will need to load the module in to the kernel. This can be done by running the following command:

You should now be able to see the file. This is a compressed copy of the entire kernel configuration at build time.

When you're finished looking at the configuration, you can unload the module with

The module should now have been unloaded and the file removed.

Reading IKCONFIG
In case you hadn't guessed from the filename extension, the configuration file that is now in your directory is a compressed copy of your kernel configuration, which means that in order to read it, it needs to be decompressed. There are two ways to go about doing this.

Quick queries
If you just need to check one or two options, then the easiest way to read the file is to cat it to the decompressor, and then use grep to find what you're looking for.

Full file
Alternatively, if you want a more in-depth look at the configuration of the running kernel, you will need to copy the compressed file from where it is and decompress it.

Optional: Load module on boot
If you build your kernel with IKCONFIG support as a module, and want that module loaded when you system boots, you will need to add it to the list of auto-loaded modules for your system. For example, with OpenRC: /etc/conf.d/modules