天天看點

centos 編譯核心至2.6.39.4

一、下載下傳核心檔案并解壓至相應目錄

# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.4.tar.bz2 

# tar jxvf linux-2.6.39.4.tar.bz2

# mv linux-2.6.39.4 /usr/src

二、簡要的配置核心

# cd /usr/src/linux-2.6.39.4 

# make mrproper //第一次編譯無需運作此指令,如果之前有編譯過,則需要 

# cp /boot/config-`uname -r` .config //copy一份目前系統的核心配置檔案作參考 

# make menuconfig  

下面兩個需要選中(兩個都選中),確定.config檔案中有該項

CONFIG_SYSFS_DEPRECATED_V2 = y 

否則編譯完成重新開機系統時會有如下錯誤輸出:

mount: could not find filesystem '/dev/root'  

Setting up other filesystems.  

Setting up new root fs  

setuproot: moving /dev failed: No such file or directory  

no fstab.sys, mounting internal defaults  

setuproot: error mounting /proc: No such file or directory  

setuproot: error mounting /sys: No such file or directory  

Switching to new root and running init.  

unmounting old /dev  

unmounting old /proc  

unmounting old /sys  

switchroot: mount failed: No such file or directory  

Kernel panic - not syncing: Attempted to kill init! 

<a target="_blank" href="http://blog.51cto.com/attachment/201109/143744486.png"></a>

加上ext4的支援

<a target="_blank" href="http://blog.51cto.com/attachment/201109/144207400.png"></a>

然後儲存即可

三、安裝編譯核心

# make all 

# make modules_install 

# make install 

完了,修改grub啟動檔案,以新核心啟動系統便可。

PS:如果這樣就以新核心啟動,系統重新開機時會報一個錯誤

insmod: error inserting ‘/lib/dm-region-hash.ko’: –1 File exits 

這ms是2.6核心的Bug,需要修改核心,并重新生成新核心檔案

解壓修改核心步驟

# cp /boot/initrd-2.6.39.4.img /tmp/ 

# cd /tmp/ 

# mkdir newinitrd 

# cd newinitrd/ 

# zcat ../initrd-2.6.39.4.img |cpio -i  

# rm -f /tmp/initrd-2.6.39.4.img 

# vi init 

找到這4行一樣的,去掉相同的2行 

echo "Loading dm-region-hash.ko module"  

insmod /lib/dm-region-hash.ko  

重新打包核心

# find .|cpio -c -o &gt;../initrd 

# cd ..; gzip -9 &lt; initrd &gt; initrd-2.6.39.4.img 

# cp initrd-2.6.39.4.img /boot/ 

本文轉自dongfang_09859 51CTO部落格,原文連結:http://blog.51cto.com/hellosa/658107,如需轉載請自行聯系原作者

繼續閱讀