歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 內核升級(2.6.18-194.el5升2.6.30)

CentOS 內核升級(2.6.18-194.el5升2.6.30)

日期:2017/2/28 16:30:22   编辑:Linux教程

因要測試一些軟件,需要2.6.30以上的內核,安裝好CentOS 5.5,內核是2.6.18-194.el5.這次的升級還算比較順利,具體的過程如下:
[root@localhost ~]# uname -r
2.6.18-194.el5
1.下載linux-2.6.30內核包到/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 清除環境變量,即清除配置文件
make menuconfig 在菜單模式下選擇需要編譯的內核模塊:

networking support—>networking options—>network packet filtering framework(netfilter)

(1).core netfilter configuration
A 勾中”Netfilter connection tracking support” -m state相關模塊是依賴它的,不選則沒有。
B 將netbios name service protocal support(new) 編譯成模塊,不然後面升級iptables後啟動時會出錯
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).其它模塊可以根據自己的需要進行選擇,若不懂可以參考內核配置手冊.

make clean 確保所有東西均保持最新狀態.
make bzImage 生成內核文件
make modules 編譯模塊
make modules_install 安裝模塊
make install 安裝
mkinitrd /boot/initrd_2.6.30.img 2.6.30 根據內核版本和指定參數生成映像文件
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.此步若沒有操作,重啟會報錯”insmod: error inserting ‘/lib/dm-region-hash.ko’: –1 File exits”,原因是重復了,根據網上查到的資料,2.6.x自編譯內核會有這個小bug,我測試過不修改直接重啟,雖然有報錯,但仍然可以進入系統的.

[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 刪掉重復的如下兩行:
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.重啟成功後,再看看內核,是2.6.30,ok了。
[root@localhost ~]# uname -r
2.6.30

Copyright © Linux教程網 All Rights Reserved