手记

centos内核升级文档

 1、查看当前系统内核

# uname -r
2 2.6.32-71.el6.i686

2、下载linux-3.2.2内核包[l1] 

# cd ~
# wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.2.tar.bz2
# tar jxvf linux-3.2.2.tar.bz2
# cd linux-3.2.2

3、配置内核并安装

# make mrproper  #清除环境变量,即清除配置文件
# make menuconfig  #
在菜单模式下选择需要编译的内核模块
[l2] 

(注:这一步不知道可以直接使用默认即可,或者查看帮助文件)

模块可以根据自己的需要进行选择,若不懂可以参考内核配置手册.

执行完make menuconfig后,修改/usr/src/linux-2.6.35.4/.config
#CONFIG_SYSFS_DEPRECATED_V2 is not set
默认被注释掉的,将其改为y。即修改为
CONFIG_SYSFS_DEPRECATED_V2=y
[l3] 再接着编译安装内核

 

# make clean #确保所有东西均保持最新状态.
# make bzImage #
生成内核文件
# make modules #
编译模块
# make modules_install #
安装模块
# make install #
安装

4、编辑 /etc/grub.conf 文件,将 default=1 改为 default=0[l4] 

# 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/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS Linux (3.2.2)
root (hd0,0)
kernel /vmlinuz-3.2.2 ro root=/dev/mapper/VolGroup-lv_root rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-3.2.2.img
title centos (2.6.32-71.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.el6.i686.img

5、重启系统,并查看内核

# reboot
# uname -r

3.2.

升级成功!

 

 

 

#升级过程中遇到的问题
一、启动报错
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文件
[root@vhost ~]# cp /boot/initrd-2.6.35.4.img /tmp
[root@vhost ~]# cd /tmp/
[root@vhost tmp]# ls
initrd-2.6.35.4.img
[root@vhost tmp]# mkdir newinitrd
[root@vhost tmp]# cd newinitrd/
[root@vhost newinitrd]# zcat ../initrd-2.6.35.4.img |cpio -i
11282 blocks
释放之后看到如下内容
[root@vhost 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
[root@vhost newinitrd]# find .|cpio -c -o > ../initrd
11282 blocks
[root@vhost newinitrd]# cd ..
[root@vhost tmp]# gzip -9 < initrd > initrd.img
[root@vhost tmp]# ls
initrd-2.6.35.4.img    initrd    initrd.img          newinitrd

initrd.img就是重新打包的initrd了,然后把initrd.img拷贝到/boot
[root@vhost tmp]# mv /boot/initrd-2.6.35.4.img /boot/initrd-2.6.35.4.img.bak
[root@vhost tmp]# mv initrd.img /boot/initrd-2.6.35.4.img
[root@vhost tmp]# reboot
这样“insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists” 就不会有了



0人推荐
随时随地看视频
慕课网APP