在 CentOS 上編譯核心,通常需要下載源碼、清理環境、設定選項、編譯壓縮映像與模組,最後安裝並調整開機選單。
wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.tar.gz tar -zxvf linux-2.6.29.tar.gz cd /usr/src/linux-2.6.29
若源碼不是全新解壓,可先清理:
make mrproper make clean
沿用目前核心設定並開啟選單:
cp /boot/config-xx.xx.xx .config make menuconfig
若缺少 ncurses,可安裝:
yum install ncurses-devel
make bzImage make modules make modules_install make install
make bzImage 會產生壓縮核心映像,make modules 編譯模組,make modules_install 會安裝到 /lib/modules,make install 則會在 /boot 產生相關檔案。
修改 /boot/grub/menu.lst,將新核心設為預設啟動項,然後重新啟動:
reboot
若找不到核心模組,可手動複製 bzImage 與 System.map 到 /boot,再重新整理開機設定。