centos6.4升级内核版本详解

1.查看当前内核版本和内核参数配置

1.查看当前内核版本和内核参数配置
[root@proxy ~]# uname -r
2.6.32-358.el6.x86_64

[root@proxy ~]# 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/sda3
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-358.el6.x86_64)
	root (hd0,0)
	kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=b3c05d05-38bb-4cdd-864e-9c59cdcab2a0 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-358.el6.x86_64.img

2.下载解压linux-3.4.56.tar.xz内核版本包

[root@proxy src]# wget -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.4.56.tar.xz
[root@proxy src]# tar xf linux-3.4.56.tar.xz
[root@proxy src]# cd linux-3.4.56

3.配置安装内核

[root@proxy linux-3.4.56]# make mrproper                #清除环境变量,即清除配置文件
[root@proxy linux-3.4.56]# make menuconfig              #在菜单模式下选择需要编译的内核模块
找到以下选中选项并选中networking support → networking options → network packet filtering framework(netfilter)

(1).core netfilter configuration

勾中”Netfilter connection tracking support” -m state相关模块是依赖它的,不选则没有。
将netbios name service protocal support(new) 编译成模块,不然后面升级iptables后启动时会出错
勾中“Netfilter Xtables support (required for ip_tables)”
(2).IP: Netfilter Configuration

将 “IPv4 connection tracking support (require for NAT)” 编译成模块。
勾中IP tables support (required for filtering/masq/NAT) 。
将 “Full NAT” 下的 “MASQUERADE target support” 和 “REDIRECT target support” 编译成模块
(3).其它模块可以根据自己的需要进行选择,若不懂可以参考内核配置手册.

[root@proxy linux-3.4.56]# make clean                   #确保所有东西均保持最新状态.
[root@proxy linux-3.4.56]# make bzImage                 #生成内核文件
[root@proxy linux-3.4.56]# make modules                 #编译模块
[root@proxy linux-3.4.56]# make modules_install         #安装模块
[root@proxy linux-3.4.56]# make install                 #安装
make modules 和 make modules_install 这两步安装时间较长,请耐心等待!

4.查看/etc/grub.conf内核配置文件变化

[root@proxy ~]# 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/sda3
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.4.56)
	root (hd0,0)
	kernel /vmlinuz-3.4.56 ro root=UUID=b3c05d05-38bb-4cdd-864e-9c59cdcab2a0 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
	initrd /initramfs-3.4.56.img
title CentOS (2.6.32-358.el6.x86_64)
	root (hd0,0)
	kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=b3c05d05-38bb-4cdd-864e-9c59cdcab2a0 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-358.el6.x86_64.img
从上面可以发现,新编译的内核已经ok!

5.修改系统启动内核选择

将/etc/grub.conf文件中default=1修改为default=0
[root@proxy ~]# sed -i 's/default=1/default=0/g' /etc/grub.conf

6.重启系统,让新内核加载生效

[root@proxy ~]# reboot

7.重新登陆系统验证内核版本

[root@proxy ~]# uname -r
3.4.56

0 个评论

要回复文章请先登录注册