1、查看/boot/grub/grub.conf,grub的启动选项如下,有两个选项
# 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,9)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_yangcentos-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=0
timeout=10
splashimage=(hd0,9)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.5.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-431.5.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.5.1.el6.i686.img
title Windows 7
rootnoverify (hd0,0)
chainloader +1
2、从www.kernel.org网站下载linux-3.12.14内核包
# cd ~ #当前工作目录设为root的家目录 # wget -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.12.14.tar.xz # tar -Jxvf linux-3.12.14.tar.xz # mv linux-3.12.14 /usr/src/kernels/linux-3.12.14 # cd /usr/src/kernels/linux-3.4.56 #将当前工作目录设为linux源文件所在目录
3、编译、安装内核源代码
# make mrproper #第一次安装3.x版本的内核,清除环境变量,即清除配置文件和可能的.o文件 # make menuconfig #在菜单模式下选择需要编译的内核模块,这一步都采用系统默认配置即可
# make clean #确保所有东西均保持最新状态.编译前清除可能的.o等编译中间文件 # make bzImage #生成内核文件 # make modules #编译模块,内核编译和驱动编译花的时间比较长,耐心等待 # make modules_install #安装模块 # make install #安装
4、安装完后,再查看/boot/grub/grub.conf
与第一步的内容比较发现,新的文件default值由0改为了1,同时多了3.12.14内核版本的选单,也就是我们安装的内核
# 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,9)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_yangcentos-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=1
timeout=10
splashimage=(hd0,9)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.12.14)
root (hd0,9)
kernel /vmlinuz-3.12.14 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-3.12.14.img
title CentOS (2.6.32-431.5.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-431.5.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.5.1.el6.i686.img
title Windows 7
rootnoverify (hd0,0)
chainloader +1
5、将grub.conf文件的default重新改为0,默认启动3.12.14版本的内核
6、重新启动电脑
#reboot