歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 5.5編譯升級2.6.35.13內核完整筆記

CentOS 5.5編譯升級2.6.35.13內核完整筆記

日期:2017/2/28 15:53:55   编辑:Linux教程

文檔信息:
文檔版本:Version 1.0
修改記錄:2012-3-25
系統環境:CentOS 5.5(適合32bit and 64bit)
格式約定:
灰色底:輸入的系統命令
黃色底:輸入的系統命令返回的信息或者配置文件文本信息
綠色底:技巧或需要注意的地方
紅色底:需要特別注意的地方
藍色字:內容注釋
===================================================================
CentOS 5.5所帶的內核還是比較老(2.6.18版),所以本次編譯升級了性能比較好的2.6.35.X系列穩定內核2.6.35.13版,並做以下筆錄!
1)下載新內核
從官方網站下載2.6.35.13版本:http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.35/linux-2.6.35.13.tar.bz2,然後通過Filezilla上傳至/usr/src/kernels目錄

2)解壓新內核
[root@server ~]# cd /usr/src/kernels/
[root@server kernels]# ls
linux-2.6.35.13.tar.bz2
[root@server kernels]# tar jxvf linux-2.6.35.13.tar.bz2
3)開始編譯內核
[root@server kernels]# cd linux-2.6.35.13
[root@server linux-2.6.35.13]# make mrproper
[root@server linux-2.6.35.13]# make menuconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/docproc
HOSTCC scripts/basic/hash
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/kxgettext.o
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel) and try again.
***
make[1]: *** [scripts/kconfig/dochecklxdialog] 錯誤 1
make: *** [menuconfig] 錯誤 2
[root@server linux-2.6.35.13]# yum -y install ncurses-devel
[root@server linux-2.6.35.13]# make menuconfig
[root@server linux-2.6.35.13]# make all
[root@server linux-2.6.35.13]# make modules
此時出現“WARING:modpost:Found 2 section mismatch(es).”錯誤提示,如下:
650) this.width=650;" border=0>
那麼重新敲入:make CONFIG_DEBUG_SECTION_MISMATCH=y 編譯
[root@server linux-2.6.35.13]# make CONFIG_DEBUG_SECTION_MISMATCH=y
編譯完成後,再重新編譯內核模塊
[root@server linux-2.6.35.13]# make modules
[root@server linux-2.6.35.13]# make modules_install
[root@server linux-2.6.35.13]# make install
sh /usr/src/kernels/linux-2.6.35.13/arch/x86/boot/install.sh 2.6.35.13 arch/x86/boot/bzImage \
System.map "/boot"
如果只是按上述步驟完成編譯,重啟加載新內核啟動會報如下類似錯誤:
650) this.width=650;" border=0>
經過搜索後,發現此類問題多集中在邏輯卷管理的情況,具體原因是在編譯升級內核時沒有加載一些邏輯卷,因此在執行完“make all”之後“linux-2.6.35.13”文件夾下會生成配置文件“.config”, 要先編輯此文件:
改“#CONFIG_SYSFS_DEPRECATED_V2 is not set”為“CONFIG_SYSFS_DEPRECATED_V2=y”
或者直接用下面sed命令更改:
[root@server linux-2.6.35.13]# sed -i 's/# CONFIG_SYSFS_DEPRECATED_V2 is not set/CONFIG_SYSFS_DEPRECATED_V2=y/' .config
修改完此配置文件後再次“make all”以及完成後續步驟。
[root@server linux-2.6.35.13]# make all
[root@server linux-2.6.35.13]# make CONFIG_DEBUG_SECTION_MISMATCH=y
[root@server linux-2.6.35.13]# make modules
[root@server linux-2.6.35.13]# make modules_install
[root@server linux-2.6.35.13]# make install
4)解壓initrd文件
[root@server linux-2.6.35.13]# cp /boot/initrd-2.6.35.13.img /tmp
[root@server linux-2.6.35.13]# cd /tmp/
[root@server tmp]# mkdir newinitrd
[root@server tmp]# cd newinitrd/
[root@server newinitrd]# zcat ../initrd-2.6.35.13.img |cpio -i
[root@server newinitrd]# vi init
# 刪掉重復的兩行其中一行
echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko
echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko
5)重新打包initrd文件
[root@server newinitrd]# find .|cpio -c -o > ../initrd
11286 blocks
[root@server newinitrd]# cd ../
[root@server tmp]# gzip -9 < initrd > initrd-2.6.35.13.img
[root@server tmp]# rm -rf /boot/initrd-2.6.35.13.img
[root@server tmp]# cp initrd-2.6.35.13.img /boot
6)修改默認以新的內核啟動
[root@server tmp]# less /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/hdd3
# initrd /initrd-version.img
#boot=/dev/hdd
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.35.13)
root (hd0,0)
kernel /vmlinuz-2.6.35.13 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.35.13.img
title CentOS (2.6.18-194.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-194.el5.img
[root@server tmp]# vi /boot/grub/grub.conf
把default=1改為default=0,然後重新啟動系統
[root@server tmp]# reboot
7)重啟後驗證內核版本
650) this.width=650;" border=0>

Copyright © Linux教程網 All Rights Reserved