温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

centos内核升级文档

发布时间:2020-07-08 12:41:06 来源:网络 阅读:769 作者:bailianhua1005 栏目:web开发

 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
splashp_w_picpath=(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” 就不会有了


 [l1]关于如何选择内核版本,首先要根据自己的需要,比如我要升级ext4系统,那么必须选择2.6.28以上版本;还有偶数版本一般为稳定版

下载版本到http://www.kernel.org/pub/linux/kernel去下载就可以

 

 

 [l2]注:这一步也是根据需要选择相应模块,选项分三种--(不包含,以模块形式,编入内核);不知道可以直接使用默认即可,或者查看帮助文件

 [l3]这一步一定要先做,否则在升级后自检报错:mount: could not find filesystem /dev/root

 [l4]不必急着删老版本,更改默认启动新内核即可,在确认新内核升级正常后再删老内核也不迟

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI