週日早晨,在離線環境下於實體機器編譯 Linux 2.6.11 核心,記錄完整過程供參考。
# tar -zxvf module-init-tools-3.0.tar.gz # cd module-init-tools-3.0 # ./configure --prefix=/sbin # make # make install # ./generate-modprobe.conf /etc/modprobe.conf
實測 3.1 版 make 失敗,3.0 版順利通過。
# rpm -Uvih modutils-2.4.25-8.9.i386.rpm
# tar xzvf linux-2.6.11.tar.gz -C /usr/src # cd /usr/src # rm -f linux # ln -s linux-2.6.11 linux # cd /usr/src/linux # make mrproper
目標皆為產生 .config 檔案:
make config — 文字傳統介面,不推薦make menuconfig — 文字選單介面,字元終端首選make xconfig — 圖形視窗介面,需 X Window,最友善make oldconfig — 基於舊配置微調,省時有 X 環境優先用 make xconfig,否則用 make menuconfig。配置時遇三種選項:Y(編入核心)、N(不編入)、M(編譯為模組,動態載入)。menuconfig 中空格鍵切換:中括號 [*] 表編入核心;尖括號 <*> 或 <M> 可選模組;圓括號為單選。
Code maturity level options ---> [*] Prompt for development and/or incomplete code/drivers [*] Select only drivers expected to compile cleanly
啟用後可見開發中/不完整驅動選項,需使用新功能時開啟。
General setup ---> () Local version - append to kernel release (≤64 字元,uname -a 可見) [*] Support for paging of anonymous memory (swap) # 必選 [*] System V IPC # 必選,否則多程式無法運行 [*] POSIX Message Queues # 建議選上 [*] BSD Process Accounting # 建議選上 [*] BSD Process Accounting version 3 file format [*] Sysctl support # 配合 /proc 動態調整參數,建議選上 [ ] Auditing support # 僅 SELinux 等需要時選擇 (15) Kernel log buffer size (16=>64KB, 17=>128KB) # 依架構選擇 [*] Support for hot-pluggable devices # 必選 [*] Kernel Userspace Events # 核心與用戶空間通訊,選上 [*] Kernel .config support # 將配置存入核心,可從 /proc/config.gz 讀取 [*] Enable access to .config through /proc/config.gz [ ] Configure standard kernel features (for small systems) # 一般不選 [ ] Load all symbols for debugging/kksymoops # 無核心除錯需求可不選 [*] Enable futex support # 不選 glibc 程式可能異常,建議選上 [*] Enable eventpoll support # 事件輪詢系統調用,最好選上 [*] Optimize for size # 用 -Os 而非 -O2,核心更小,建議選上 [*] Use full shmem filesystem # 除非記憶體極少且無 swap,否則選上 (0) Function/Label/Loop/Jump alignment
Loadable module support ---> [*] Enable loadable module support [*] Module unloading # 不選則模組無法卸載 [ ] Forced module unloading [ ] Module versioning support (EXPERIMENTAL) [ ] Source checksum for all modules [*] Automatic kernel module loading
Processor type and features ---> Subarchitecture Type (PC-compatible) ---> Processor family (Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon) ---> [ ] Generic x86 support # 選 i386/i586 時啟用 [*] HPET Timer Support # 下一代計時器,硬體不支援會回退 8254 [*] Symmetric multi-processing support # SMP;單 CPU 不選或許更快,但超執緒顯示雙核心,建議選上 (1) Maximum number of CPUs (2-255) [ ] SMT (Hyperthreading) scheduler support [*] Preemptible Kernel # 核心高負載時應用程式仍可靈敏,建議選上 [*] Machine Check Exception # CPU 故障通知核心,組裝機建議選上 Firmware Drivers ---> <> BIOS Enhanced Disk Drive calls determine boot disk (EXPERIMENTAL) High Memory Support (4GB) ---> [ ] Allocate 3rd-level pagetables from highmem [ ] Math emulation [*] MTRR (Memory Type Range Register) support [ ] Boot from EFI support (EXPERIMENTAL) [*] Enable kernel irq balancing [ ] Use register arguments (EXPERIMENTAL)
Power management options (ACPI, APM) ---> [*] Power Management support [ ] Power Management Debug Support [ ] Software Suspend (EXPERIMENTAL) ACPI Support ---> [*] ACPI Support # BIOS 支援則建議選上 [ ] Sleep States (EXPERIMENTAL) <> AC Adapter <> Battery <*> Button # 捕獲 Power/Sleep/Lid 按鍵觸發動作 <*> Video # 整合顯卡 ACPI 支援,部分板卡可能無效 <> Fan APM BIOS Support ---> CPU Frequency scaling --->
(配置內容未完,後續將續補)