User:Egberts/Drafts/Gentoo Kernel Configuration Guide

From Gentoo Wiki
Jump to:navigation Jump to:search
Note
Editor: this section gets inserted into Kernel/Gentoo Kernel Configuration Guide or into Kernel/Configuration

Advanced kernel configurations

Linux kernel also has provided two scripts to assist with updating kernel configuration settings (without having to tediously navigate through make menuconfig:

  • change a single setting; linux/scripts/config command (introduced 3.33rc1+)
  • change many kernel configuration settings; linux/scripts/kconfig/merge_config.sh command (introduced 2.6.29-rc1+)

Single option approach

One way to change the linux/.config at the command line is to change one-line/setting per command evocation.

An example of changing five(5) kernel configuration settings is shown below:

root # cd /usr/src/linux
root #./scripts/config --set-val CONFIG_OPTION y
root #./scripts/config --enable CONFIG_BRIDGE
root #./scripts/config --enable CONFIG_MODULES
root #./scripts/config --disable CONFIG_X25
root #./scripts/config --module CONFIG_NFT
root # make oldconfig

The purpose of the make oldconfig is to go over the entire kernel configuration settings and make additional changes based on Kconfig dependency logic.

Warning
it is possible that a setting will revert back to its old value due to and by dependencies of other settings. For exmaple, trying to be turning off CONFIG_INITRAMFS will flip back on due to CONFIG_MODULES forces the requirement of re-enabling initramfs back to enabled.


The merge_config [1] command is detailed here.

Multiple-file merge approach

When building and customizing Linux kernel repeatedly, it becomes a time-saver to incorporate all the settings into a single (but smaller) kernel configuration file. Each kernel configuration file would represent a certain feature, device, or functionality.

This makes grouping of many settings of kernel configurations less forgetful and easily referenced by a (descriptive) filename that can be easily inserted into a Linux kernel configuration.

Given the two example files:

FILE /usr/src/kernel-config-qemu-always-on.configSpecific purpose kernel config file
CONFIG_HIBERNATION=n
CONFIG_AUTOSLEEP=n
CONFIG_ACPI_SLEEP=n
CONFIG_PM_SLEEP=n
FILE /usr/src/kernel-config-accessibility-readable.configReadable terminal
# Terminus Font is a clean, fixed width bitmap font,
# designed for long (8 and more hours per day) work with
# computers.  This is the high resolution, large version
# for use with HiDPI screens.
CONFIG_FONTS=y
CONFIG_FONT_SUPPORT=y
CONFIG_FONT_TER16x32=y
root #./scripts/kconfig/merge_config.sh kernel-kconfig-accessibility-readability.config
root #./scripts/kconfig/merge_config.sh kernel-kconfig-qemu-always-on.config # Auto-add/auto-remove CONFIG_ dependencies
root #make oldconfig

The command to update the default /usr/src/linux/.config file is:

root #cd /usr/src/linux
root #scripts/kconfig/merge_config.sh my-kernel-config-gkcg.config

Now the kernel will incorporate both readable terminals and ensure that it would never hibernate nor sleep.

References