Linux内核编译
基于Ubuntu23.04编译最新版Linux内核(6.8.9),并解决编译过程中的相关问题。
根据出现的问题,需要安装一下软件:sudo apt install flex bc libelf-dev
,并禁用系统相关证书:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
源码下载:
中科大镜像站:Index of /kernel.org/ (ustc.edu.cn)
下载内核源码:wget https://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v6.x/linux-6.8.9.tar.gz
问题
问题1:make menuconfig
时提示flex: not found
错误日志:
/bin/sh: 1: flex: not found
make[2]: *** [scripts/Makefile.host:9: scripts/kconfig/lexer.lex.c] Error 127
make[1]: *** [/home/blduan/opensrcs/linux-6.8.9/Makefile:689: menuconfig] Error 2
make: *** [Makefile:240: __sub-make] Error 2
解决方案:
sudo apt install flex
问题2:make
时提示bc: not found
错误日志:
/bin/sh: 1: bc: not found
make[2]: *** [Kbuild:24: include/generated/timeconst.h] Error 127
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/home/blduan/opensrcs/linux-6.8.9/Makefile:1199: prepare0] Error 2
make: *** [Makefile:240: __sub-make] Error 2
解决方案:
sudo apt install bc
问题3:<stdin>:1:10: fatal error: libelf.h: No such file or directory
错误日志:
mkdir -p /home/blduan/opensrcs/linux-6.8.9/tools/objtool && make O=/home/blduan/opensrcs/linux-6.8.9 subdir=tools/objtool --no-print-directory -C objtool
<stdin>:1:10: fatal error: libelf.h: No such file or directory
compilation terminated.
UPD include/generated/timeconst.h
UPD include/generated/bounds.h
CC arch/x86/kernel/asm-offsets.s
INSTALL libsubcmd_headers
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/check.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/weak.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/arch/x86/special.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/special.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/elf.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/arch/x86/decode.o
CC /home/blduan/opensrcs/linux-6.8.9/tools/objtool/builtin-check.o
In file included from /home/blduan/opensrcs/linux-6.8.9/tools/objtool/include/objtool/objtool.h:13,
from /home/blduan/opensrcs/linux-6.8.9/tools/objtool/include/objtool/arch.h:11,
from check.c:13:
/home/blduan/opensrcs/linux-6.8.9/tools/objtool/include/objtool/elf.h:10:10: fatal error: gelf.h: No such file or directory
10 | #include <gelf.h>
| ^~~~~~~~
compilation terminated.
解决方案:
sudo apt install libelf-dev
问题4:*** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'.
错误日志:
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
make[3]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'. Stop.
make[2]: *** [scripts/Makefile.build:481: certs] Error 2
make[1]: *** [/home/blduan/opensrcs/linux-6.8.9/Makefile:1921: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2
解决方案:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
- 原文作者:生如夏花
- 原文链接:https://blduan.top/post/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/linux%E5%86%85%E6%A0%B8%E7%BC%96%E8%AF%91/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。