安装包
yum -y install ncurses-devel openssl-devel elfutils-libelf-devel
下载内核 解压
cd /usr/src/
wget -c https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.13.tar.xz
tar xf linux-4.10.13.tar.xz
编译
cp /boot/config-3.10.0-514.16.1.el7.x86_64 .config
make menuconfig
弹出如下对话框,选择 Load(可以按 TAB 键选择),然后加载本地的.config文件
其中:[]
或<>
表示未选择[M]
或 <M>
表示编译成模块[*]
或<*>
表示编译进内核
比如说我们要将 BBR 这个模块进行编译,我们需要找到
Networking Support —> Network options—> TCP: Advanced congestion algorithm 选择 BBR,在其前面的
然后保存后退出,执行
make prepare #清理之前编译留下的垃圾,如果第一次编译,可以忽略
make -j 4 # 开启4线程进行编译,速度更快,需要 CPU 支持
make modules_install #编译模块
make install #安装
执行如下命令
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
会出现如下内容
0 : CentOS Linux (4.10.13) 7 (Core)
1 : CentOS Linux (3.10.0-514.16.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-ea321ca5d6ef4103bbcfb9e680e0759e) 7 (Core)
设置第0项为开机默认启动项
grub2-set-default 0
重启查看
[root@localhost ~]# uname -r
4.10.13