歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 5.5升級內核到2.6.35.4

CentOS 5.5升級內核到2.6.35.4

日期:2017/2/28 16:17:01   编辑:Linux教程

當前系統版本為CentOS 5.5,內核版本為2.6.18-194,現將內核升級到2.6.35.4

[[email protected] data]# wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.4.tar.bz2
[[email protected] data]# tar -jxvf linux-2.6.35.4.tar.bz2
[[email protected] data]# mv linux-2.6.35.4 /usr/src
[[email protected] data]# cd /usr/src/linux-2.6.35.4
#配置內核參數,選擇自己所需的模塊
[[email protected] linux-2.6.35.4]# make menuconfig
#編譯安裝內核
[[email protected] linux-2.6.35.4]# make
[[email protected] linux-2.6.35.4]# make modules
[[email protected] linux-2.6.35.4]# make modules_install
[[email protected] linux-2.6.35.4]# make install

#修改默認以新的內核啟動。
[[email protected] linux-2.6.35.4]# vi /boot/grub/grub.conf
default=0
#將新的內核配置文件復制到/boot目錄。
[[email protected] linux-2.6.35.4]# cp /usr/src/linux-2.6.35.4/.config /boot/config-2.6.35.4
[[email protected] linux-2.6.35.4]# reboot

#重啟後驗證內核版本
[[email protected] /]# uname -r
2.6.35.4

#升級過程中遇到的問題
一、啟動報錯
mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!

解決方法:
執行完make menuconfig後,修改/usr/src/linux-2.6.35.4/.config
將#CONFIG_SYSFS_DEPRECATED_V2 is not set
默認被注釋掉的,將其改為y。即修改為
CONFIG_SYSFS_DEPRECATED_V2=y
再接著編譯安裝內核

二、啟動報錯
insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists

解決方法:
1、解壓initrd文件
[[email protected] ~]# cp /boot/initrd-2.6.35.4.img /tmp
[[email protected] ~]# cd /tmp/
[[email protected] tmp]# ls
initrd-2.6.35.4.img
[[email protected] tmp]# mkdir newinitrd
[[email protected] tmp]# cd newinitrd/
[[email protected] newinitrd]# zcat ../initrd-2.6.35.4.img |cpio -i
11282 blocks
釋放之後看到如下內容
[[email protected] newinitrd]# ls
bin dev etc init lib proc sbin sys sysroot

2、下邊就是編輯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

3、重新打包initrd
[[email protected] newinitrd]# find .|cpio -c -o > ../initrd
11282 blocks
[[email protected] newinitrd]# cd ..
[[email protected] tmp]# gzip -9 < initrd > initrd.img
[[email protected] tmp]# ls
initrd-2.6.35.4.img initrd initrd.img newinitrd

initrd.img就是重新打包的initrd了,然後把initrd.img拷貝到/boot
[[email protected] tmp]# mv /boot/initrd-2.6.35.4.img /boot/initrd-2.6.35.4.img.bak
[[email protected] tmp]# mv initrd.img /boot/initrd-2.6.35.4.img
[[email protected] tmp]# reboot
這樣“insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists” 就不會有了

Copyright © Linux教程網 All Rights Reserved