Ubuntu20.04-server版内核编译
1.查看当前系统原码版本
wy@wy:/usr/src$ apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-5.4.0 - Linux kernel source for version 5.4.0 with Ubuntu patches
linux-gkeop-source-5.4.0 - Linux kernel source for version 5.4.0 with Ubuntu patches
linux-hwe-5.11-source-5.11.0 - Linux kernel source for version 5.11.0 with Ubuntu patches
linux-hwe-5.13-source-5.13.0 - Linux kernel source for version 5.13.0 with Ubuntu patches
linux-hwe-5.8-source-5.8.0 - Linux kernel source for version 5.8.0 with Ubuntu patches
linux-intel-5.13-source-5.13.0 - Linux kernel source for version 5.13.0 with Ubuntu patches
2.下载源码
sudo apt-get install linux-source-5.4.0
下载完成后,在/usr/src目录中,可以看到压缩包
wy@wy:~/code$ cd /usr/src/
wy@wy:/usr/src$ ls
linux-headers-5.4.0-113 linux-headers-5.4.0-113-generic linux-source-5.4.0 linux-source-5.4.0.tar.bz2
3.安装编译内核依赖
sudo apt install libncurses5-dev openssl libssl-dev build-essential pkg-config libc6-dev bison flex libelf-dev zlibc minizip libidn11-dev libidn11 qttools5-dev liblz4-tool
#如果是deepin用户看到这篇文章,还要安装如下的依赖
sudo apt install plymouth* console-setup
- 编译内核
$ tar xf linux-source-5.4.0.tar.bz2 -C ~/code/
Make -j4
make modules_install
make install
问题1:
No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'.
将下载好的*.pem相关的文件拷贝到内核的根目录下
cp /usr/src/linux-source-5.4.0/debian ./ -rf
Make -j16
问题2:
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
解决:修改.config
vim .config
修改前
修改后:
保存退出