리눅스 커널을 플랫폼 또는 목적에 맞게 빌드하기 위해서는 .config 파일을 생성하고, 적절한 옵션들을 구성해야 한다. 이 과정은 커널 빌드 전체의 품질과 기능성에 큰 영향을 미친다. 이 글에서는 커널 설정 방법에 대해 알아본다.
커널 설정 도구 종류
다음은 커널 문서에서 configuration 에 대한 설명이다.
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a Qt based front-end
gconfig - Update current config utilising a GTK+ based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
except those preserved by LMC_KEEP environment variable
localyesconfig - Update current config converting local mods to core
except those preserved by LMC_KEEP environment variable
defconfig - New config with default from ARCH supplied defconfig
savedefconfig - Save current config as ./defconfig (minimal config)
allnoconfig - New config where all options are answered with no
allyesconfig - New config where all options are accepted with yes
allmodconfig - New config selecting modules when possible
alldefconfig - New config with all symbols set to default
randconfig - New config with random answer to all options
yes2modconfig - Change answers from yes to mod if possible
mod2yesconfig - Change answers from mod to yes if possible
mod2noconfig - Change answers from mod to no if possible
listnewconfig - List new options
helpnewconfig - List new options and help text
olddefconfig - Same as oldconfig but sets new symbols to their
default value without prompting
tinyconfig - Configure the tiniest possible kernel
testconfig - Run Kconfig unit tests (requires python3 and pytest)
주요 config 를 정리하면 다음과 같다.
| 도구 | 설명 |
|---|---|
make config | 터미널 기반 질문식 설정 |
make menuconfig | ncurses 기반 텍스트 UI |
make xconfig | Qt 기반 GUI |
make nconfig | 개선된 텍스트 UI |
make defconfig | 기본 설정 적용 |
make oldconfig | .config 파일을 기반으로 현재 설정을 업데이트 |
make olddefconfig | oldconfig와 동일하지만, 새 심볼을 설정할 때 사용자에게 묻지 않고 기본값으로 설정 |
make savedefconfig | 변경된 설정만 저장 |
커널 설정 기본 흐름
# 1. 기본 설정 불러오기 (arch별 기본값)
make defconfig
# 2. 설정 UI 진입
make menuconfig
# 3. 설정 변경 후 저장 (기본: .config)
make savedefconfig # defconfig 저장
cp .config .config.bak설정 저장 및 diff 보기
변경된 설정만 저장
make savedefconfig
생성된 defconfig는 arch/$(ARCH)/configs/에 복사하여 사용할 수 있다:
cp defconfig arch/arm64/configs/myboard_defconfig
기존 config와 차이 보기
diff -u defconfig arch/arm64/configs/myboard_defconfig
Yocto 또는 Build System에서 설정하는 방법
local.conf에서 .config 직접 수정은 지양
Yocto에서는 .config가 recipe에 의해 매번 덮어씌워지기 때문에 아래 방법 사용:
방법 1: .cfg 파일로 설정 추가
# recipes-kernel/linux/linux-yocto/myconfig.cfg
CONFIG_CMA=y
CONFIG_SCHED_CLASS_EXT=y방법 2: .bbappend + SRC_URI += "file://myconfig.cfg"
# linux-yocto_%.bbappend
SRC_URI += "file://myconfig.cfg"
do_configure:append() {
oe_runmake olddefconfig
}