Centos 源码编译指定版本内核

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 下载目标内核源。例如:
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.49.tar.xz
tar -xf linux-4.14.49.tar.xz
cd linux-4.14.49

# 应用补丁 (https://github.com/wavezhang/k8s-ipvs-toa)
patch -p1 < ../k8s-ipvs-toa/k8s-ipvs.patch

# 踩了很多坑,需要安装很多工具
yum groupinstall "Development Tools" -y

yum install openssl patch gcc automake autoconf libtool make \
zlib-devel elfutils elfutils-libelf-devel -y

yum install epel-release -y
yum install openssl-devel bc -y
yum install ncurses-devel ntpdate -y


cp /boot/config-3.10.0-229.el7.x86_64 .config

sh -c 'yes "" | make oldconfig'

make -j30 bzImage

make -j30 modules

make -j30 modules_install

make install


# 查看插入顺序,看一下
cat /boot/grub2/grub.cfg |grep "menuentry "
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

# 修改启动顺序
grub2-set-default 'CentOS Linux (4.14.49) 7 (Core)'

# 查看启动顺序
grub2-editenv list

# 重启生效
reboot

编译指定(toa)模块

1
2
3
4
5
6
7
8
9
10
11
12
# toa 模块
wget https://github.com/Huawei/TCP_option_address/archive/master.zip

unzip master.zip
cd TCP_option_address-master/src

# 编译,加载模块
make
insmod toa.ko

# 查看模块
lsmod | grep toa