本文参考转载http://linux.vbird.org/linux_basic/0540kernel.php#make_module 鸟哥的linux私房菜。提供两个方法,(听说)第一个方法适合内核小范围更新,不适合一次更新到最新的内核。 一、 [root@www1 ~]# uname -r #当前内核 3.10.0-327.el7.x86_64 [root@www1 ~]# tar -xf linux-3.11.tar.xz -C /usr/src #下载内核 [root@www1 ~]# cd /usr/src/; ls [root@www1 src]# ln -s linux-3.11 linux [root@www1 src]# cd linux [root@www1 linux]# cp /boot/config-3.10.0-327.el7.x86_64 .config [root@www1 linux]# make help [root@www1 linux]# make menuconfig #yum -y install ncurses-devel #打开内核编译界面,随便(或根据需要)做个小改动测试 [root@www1 linux]# screen #用screen界面编译,在编译过程出现断线时,还能继续编译,用法请自行man [root@www1 linux]# make -j 4 [root@www1 linux]# make modules_install [root@www1 linux]# make install [root@www1 linux]# reboot #编译完成重启系统

二、升级到新版内核(含升级过程中出现的错误提示) [root@www1 ~]# wget http://elrepo.org/linux/kernel/el7/SRPMS/kernel-lt-4.4.143-1.el7.elrepo.nosrc.rpm [root@www1 ~]# rpm -ivh kernel-lt-4.4.143-1.el7.elrepo.nosrc.rpm warning: kernel-lt-4.4.143-1.el7.elrepo.nosrc.rpm: Header V4 DSA/SHA1 Signature, key ID baadae52: NOKEY Updating / installing... 1:kernel-lt-4.4.143-1.el7.elrepo ################################# [100%] warning: user ajb does not exist - using root [root@www1 ~]# useradd -s /sbin/nologin ajb [root@www1 ~]# cd rpmbuild/SOURCES/ [root@www1 SOURCES]# vim config-4.4.143-x86_64 5813 CONFIG_VFIO_PCI_VGA=y [root@www1 SOURCES]# cd ../SPECS/ [root@www1 SPECS]# vim kernel-lt-4.4.spec 145 Source0:linux-%{LKAver}.tar.xz [root@www1 SPECS]# yum install asciidoc openssl-devel xmlto audit-libs-devel binutils-devel [root@www1 SPECS]# yum install elfutils-devel java-1.8.0-openjdk-devel newt-devel numactl-devel perl slang-devel xz-devel pciutils-devel [root@www1 SPECS]# yum install perl-devel perl-ExtUtils-Embed [root@www1 SPECS]# rpmbuild -bb kernel-lt-4.4.spec [root@www1 ~]# yum install /root/rpmbuild/RPMS/x86_64/kernel-lt-4.4.143-1.el7.centos.x86_64.rpm [root@www1 ~]# reboot [root@www1 ~]# uname -r 4.4.143-1.el7.centos.x86_64 #已成功升级内核