检查当前版本
[Long80A@VM-196~]$ uname -r
2.6.32-279.el6.x86_64
查看当前的/boot/grub/grub.conf内容:
下面使用root用户操作:
[root@VM-196~]# cat /boot/grub/grub.conf
#grub.conf generated by anaconda
#
#Note that you do not have to rerun grub after making changes to this file
#NOTICE: You do not have a /bootpartition. This means that
# all kernel and initrd paths arerelative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version roroot=/dev/sda1
# initrd/boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
titleCentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-279.el6.x86_64ro root=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet
initrd/boot/initramfs-2.6.32-279.el6.x86_64.img
[root@VM-196~]#
安装所需要的工具:
[root@VM-196~]# yum install wget gcc gc bc gd make perl ncursec-devel xz –y
如果此处,执行时遇到问题,比如:
Loaded plugins: fastestmirror, security
Determining fastest mirrors
Setting up Install Process
No package gc available.
No package ncursec-devel available.
Nothing to do
【这是由于没有配置正确yum的源导致,可通过ll /etc/yum.repos.d/来检查,看看是否是存在CentOS-Base.repo,
以及内容:
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6】
下载内核文件:
cd /usr/src
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.11.4.tar.xz# 内核文件
xz -d linux-3.11.4.tar.xz # 解压.xz
tar -xvf linux-3.11.4.tar # 解压.tar
cd linux-3.11.4
清理系统内的环境变量及依赖
make mrproper #清除环境变量
cp /boot/config-* /usr/src/kernels/ #为了方便编译配置,将/boot下的配置文件复制到当前目录下的/usr/src/kernels/文件中
make menuconfig出现General setup菜单,根据自己的需要对Kernel进行增、减。
make clean
make bzImage #生成内核文件
make modules #编译模块(注:此处需要很长时间,请耐心等待,给我的环境轻松一个半小时+)
make modules_install #安装模块
make install #安装,此处报了一个vmware的错【ERROR: modinfo: could not find module vmware_balloon】,是因为在VM中运行导致的,但不影响升级
下面修改/boot/grub/grub.conf文件,把default=1改为0
[[email protected]]# vi /boot/grub/grub.conf
#grub.conf generated by anaconda
#
#Note that you do not have to rerun grub after making changes to this file
#NOTICE: You do not have a /bootpartition. This means that
# all kernel and initrd paths arerelative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version roroot=/dev/sda1
# initrd/boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
titleCentOS (3.11.4)
root (hd0,0)
kernel /boot/vmlinuz-3.11.4 roroot=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet
initrd /boot/initramfs-3.11.4.img
titleCentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel/boot/vmlinuz-2.6.32-279.el6.x86_64 roroot=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet
initrd/boot/initramfs-2.6.32-279.el6.x86_64.img
重启之后看看版本号:
reboot
uname -r
[Long80A@VM-196 ~]$ uname -r
3.11.4
此时升级完成。