您好,登錄后才能下訂單哦!
如何輕松升級(jí)CentOS內(nèi)核,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。
因要測(cè)試一些軟件,需要2.6.30以上的內(nèi)核,安裝好CentOS 5.5,內(nèi)核是2.6.18-194.el5.這次的升級(jí)還算比較順利,具體的過程如下:
[root@localhost ~]# uname -r 2.6.18-194.el5
1.下載linux-2.6.30內(nèi)核包到/usr/src目錄
cd /usr/src wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.tar.gz tar -xzvf linux-2.6.30.tar.bz2 -C /usr/src cd linux-2.6.30 make mrproper 清除環(huán)境變量,即清除配置文件 make menuconfig 在菜單模式下選擇需要編譯的內(nèi)核模塊:
networking support—>networking options—>network packet filtering framework(netfilter)
(1).core netfilter configuration
A 勾中”Netfilter connection tracking support” -m state相關(guān)模塊是依賴它的,不選則沒有。
B 將netbios name service protocal support(new) 編譯成模塊,不然后面升級(jí)iptables后啟動(dòng)時(shí)會(huì)出錯(cuò)
C 勾中“Netfilter Xtables support (required for ip_tables)”
(2).IP: Netfilter Configuration
A 將 “IPv4 connection tracking support (require for NAT)” 編譯成模塊。
B 勾中IP tables support (required for filtering/masq/NAT) 。
C 將 “Full NAT” 下的 “MASQUERADE target support” 和 “REDIRECT target support” 編譯成模塊
(3).其它模塊可以根據(jù)自己的需要進(jìn)行選擇,若不懂可以參考內(nèi)核配置手冊(cè).
make clean 確保所有東西均保持***狀態(tài).
make bzImage 生成內(nèi)核文件
make modules 編譯模塊
make modules_install 安裝模塊
make install 安裝
mkinitrd /boot/initrd_2.6.30.img 2.6.30 根據(jù)內(nèi)核版本和指定參數(shù)生成映像文件
cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.30
cp /usr/src/linux-2.6.30/System.map /boot/System.map-2.6.30
2.在/etc/grub.conf添加如下2.6.30的信息,并把default=1改為default=0
[root@localhost ~]# cat /etc/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.18-194.el5) root (hd0,0) kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.18-194.el5.img title CentOS (2.6.30) root (hd0,0) kernel /vmlinuz-2.6.30 ro root=/dev/VolGroup00/LogVol00 rhgb quiet initrd /initrd-2.6.30.img
3.此步若沒有操作,重啟會(huì)報(bào)錯(cuò)”insmod: error inserting ‘/lib/dm-region-hash.ko’: –1 File exits”,原因是重復(fù)了,根據(jù)網(wǎng)上查到的資料,2.6.x自編譯內(nèi)核會(huì)有這個(gè)小bug,我測(cè)試過不修改直接重啟,雖然有報(bào)錯(cuò),但仍然可以進(jìn)入系統(tǒng)的.
[root@localhost]cp /boot/initrd-2.6.30.img /tmp [root@localhost]cd /tmp/ [root@localhost tmp]mkdir newinitrd [root@localhost tmp]cd newinitrd/ [root@localhost newinitrd]zcat ../initrd-2.6.30.img |cpio -i [root@localhost newinitrd]vi init 刪掉重復(fù)的如下兩行: echo “Loading dm-region-hash.ko module” insmod /lib/dm-region-hash.ko [root@localhost newinitrd]# find .|cpio -c -o > ../initrd 14765 blocks [root@localhost newinitrd]# cd .. [root@localhost tmp]# gzip -9 < initrd > initrd-2.6.30.img [root@localhost tmp]# ls gconfd-root initrd initrd-2.6.30.img mapping-root newinitrd scim-panel-socket:0-root [root@localhost tmp]# mv /boot/initrd-2.6.30.img /home/ [root@localhost tmp]# cp initrd-2.6.30.img /boot/ [root@localhost tmp]#reboot
4.重啟成功后,再看看內(nèi)核,是2.6.30,ok了。
[root@localhost ~]# uname -r 2.6.30
看完上述內(nèi)容,你們掌握如何輕松升級(jí)CentOS內(nèi)核的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。