Kconfig start configuration
If we just cloned the kernel source tree and we want to start tweaking the kernel for our system… which Kconfig configuration we should choose?
1. Default Configuration
By default Kconfig will look for kernel .config
configuration files in your system:
scripts/kconfig/Makefile
:
export KCONFIG_DEFCONFIG_LIST := ifndef cross_compiling kernel-release := $(shell uname -r) KCONFIG_DEFCONFIG_LIST += \ /lib/modules/$(kernel-release)/.config \ /etc/kernel-config \ /boot/config-$(kernel-release) endif KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
/lib/modules/$(uname -r)/.config
/etc/kernel-config
/boot/config-$(uname -r)
And if not found, it will load the default configuration for your architecture, found in
arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
:
[xubuntu@vm ../x86/configs/]$ pwd /home/xubuntu/linux-6.1.14/arch/x86/configs [xubuntu@vm ../x86/configs/]$ ls i386_defconfig tiny.config x86_64_defconfig xen.config
Default, xen, tiny, etc.
For example, tiny (literally only this):
CONFIG_NOHIGHMEM=y # CONFIG_HIGHMEM4G is not set # CONFIG_HIGHMEM64G is not set CONFIG_UNWINDER_GUESS=y # CONFIG_UNWINDER_FRAME_POINTER is not set
While x86-64 is 279 lines long:
CONFIG_WERROR=y CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_AUDIT=y CONFIG_NO_HZ=y CONFIG_HIGH_RES_TIMERS=y [..] CONFIG_SCHEDSTATS=y CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PROVIDE_OHCI1394_DMA_INIT=y CONFIG_EARLY_PRINTK_DBGP=y CONFIG_DEBUG_BOOT_PARAMS=y
2. localmodconfig approach
Another configuration approach is to get a list of current loaded kernel modules via lsmod
and then passing them to kconfig
so it configures the base kernel plus the functionality provided by these modules (disabling not loaded modules):
[xubuntu@vm ~/linux-6.1.14/]$ lsmod > lsmod [xubuntu@vm ~/linux-6.1.14/]$ make LSMOD=lsmod localmodconfig [xubuntu@vm ~/linux-6.1.14/]$ make LSMOD=lsmod localmodconfig using config: '/proc/config.gz' glue_helper config not found!! module vboxsf did not have configs CONFIG_VBOXSF_FS .config:5312:warning: symbol value '1' invalid for KASAN_STACK
Look how it’s understanding the module vboxsf
for example.
Another thing to mention is that configurations that are believed to be new from the previous configuration are still asked:
Compile also drivers which will not load (COMPILE_TEST) [N/y/?] n Compile the kernel with warnings as errors (WERROR) [N/y/?] (NEW) Local version - append to kernel release (LOCALVERSION) [-llkd01] -llkd01
See the NEW
mark appearing.