make allnoconfig
將所有選項設為 n (不編譯、不模組化),獲得理論最小配置。但此配置無法啟動,需手動啟用核心必備功能。
Executable file formats →
[*] Kernel support for ELF binaries (CONFIG_BINFMT_ELF=y)
[*] Kernel support for scripts starting with #! (CONFIG_BINFMT_SCRIPT=y)
[*] Kernel support for 32-bit ELF binaries (CONFIG_IA32_EMULATION=y) # x86_64 相容 32-bit
Processor type and features →
Processor family → 選擇實際 CPU (如 Core 2/newer Xeon, AMD Opteron/Athlon64)
[*] Symmetric multi-processing support (CONFIG_SMP=y) # 多核心支援
Bus options →
[*] PCI support (CONFIG_PCI=y)
[*] PCI Express support (CONFIG_PCIEPORTBUS=y)
Device Drivers → SCSI device support →
[*] SCSI device support (CONFIG_SCSI=y)
[*] SCSI disk support (CONFIG_BLK_DEV_SD=y)
[*] SCSI low-level drivers → 選擇具體控制器 (如 mpt3sas, megaraid_sas)
Device Drivers → Serial ATA (SATA) support →
[*] Serial ATA (SATA) support (CONFIG_ATA=y)
[*] Intel PIIX/ICH SATA support (CONFIG_ATA_PIIX=y) # 依實際硬體
File systems →
[*] Second extended fs support (CONFIG_EXT2_FS=y)
[*] Ext3 journalling file system support (CONFIG_EXT3_FS=y)
[*] Ext4 filesystem support (CONFIG_EXT4_FS=y) # 現代系統建議
# 關鍵:必須為 y (內建),不可為 m (模組),否則 pivot_root/switch_root 階段找不到驅動
Networking support → Networking options →
[*] Unix domain sockets (CONFIG_UNIX=y)
File systems → Pseudo filesystems →
[*] /proc file system support (CONFIG_PROC_FS=y)
[*] Virtual memory file system support (CONFIG_TMPFS=y) # initramfs/run/shm 基礎
[*] Tmpfs POSIX Access Control Lists (CONFIG_TMPFS_POSIX_ACL=y)
[*] Tmpfs extended attributes (CONFIG_TMPFS_XATTR=y)
General setup →
[*] Support for paging of anonymous memory (swap) (CONFIG_SWAP=y)
Device Drivers → Character devices →
[*] Enhanced Real Time Clock Support (CONFIG_RTC_CLASS=y)
[*] PC-style 'CMOS' RTC (CONFIG_RTC_DRV_CMOS=y)
make bzImage
ls -lh arch/x86/boot/bzImage
# 典型大小:~700KB - 1.2MB (視架構與驅動數量)
此配置移除所有非必要驅動 (音效、USB、網卡、無線、圖形、多餘檔案系統等),適合:
make localmodconfig (在運行目標硬體的系統上) 自動檢測已載入模組並設為內建,獲得「當前硬體最小可啟動配置」。CONFIG_IKCONFIG + CONFIG_IKCONFIG_PROC 將 .config 內建核心,zcat /proc/config.gz 可隨時查看。