记一次内核升级。


1,在 linux内核网站上下载内核文件。https://www.kernel.org/
放在 /usr/src/kernels 里面解压。
2,清除掉以前升级留下的一些不正确文件。
# cd /usr/src/kernels/linux-3.2.14
# yum install ncurses-devel #升级ncurses
# make mrporper
# cp /boot/config-‘uname -r’ /usr/src/kernels/linux3.2.14/.config #使用原来的配置文件
3. 通过菜单方式配置内核
# make menuconfig
一定要勾选(输入y选中,M编译为模块)
a、General setup→[*] enable deprecated sysfs features to support old userspace tools
b、Processor type and features→HighMemory Support。
c、找到以下选中选项并选中:
networking support → networking options → network packet filtering framework(netfilter)
(1)Corenetfilter 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" 编译成模块
4. 编译并安装内核
# make clean // 清除下内核编译的目标文件
# make bzImage // 生成内核文件
# make modules // 编码模块
# make modules_install // 安装模块
# make install // 安装

5. 编辑开机菜单选项grub文件
将 default=1 改为 default=0
# vim /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 do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (3.2.14)
root (hd0,0)
kernel /boot/vmlinuz-3.2.14 ro root=LABEL=/
initrd /boot/initrd-3.2.14.img
title Red Hat Enterprise Linux Server (2.6.18-274.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/
initrd /boot/initrd-2.6.18-274.el5.img
【保存并退出】

6. 重启
# shutdown -r "now"

7. 查看内核编译结果
# uname -r

8,删除旧内核
1. 删除 /lib/modules/ 目录下以内核的版本号为名称的目录
2. 删除掉/usr/src/kernels/目录下过时的内核源代码
3. 删除掉/boot目录下启动的核心档案以及内核映像
4. 更改/boot/grub/menu.lst,删除掉不用的启动列表

原文地址:https://www.cnblogs.com/fengfengyang/p/14100509.html