linux核心2.6升級到3.11.4
檢查當前版本
[[email protected]~]$ uname -r
2.6.32-279.el6.x86_64
檢視當前的/boot/grub/grub.conf內容:
下面使用root使用者操作:
[[email protected]~]# 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
安裝所需要的工具:
[[email protected]~]# 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
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
[[email protected] ~]$ uname -r
3.11.4
此時升級完成。