随笔 - 10  文章 - 0  评论 - 0  阅读 - 2116

Linux内核源码编译报错

make报错:

先运行make menuconfig,什么也不做退出,然后再make

 

一、137错误码报错:

在编译以下文件时可能会报137错误码:

amdgpu.o  vmlinux.o

原因:swap分区空间不足,最少需要5.5GB空间,建议保险起见10GB

在安装系统时我们一般都是采用默认的swap分区大小,普遍较小,通常在200MB左右,这就导致编译出错,这时我们就需要临时增加swap分区的大小,在编译完成后我们可以回收增加的swap分区容量。

解决方案:

步骤:扩展swap分区

#创建swap分区文件

sudo dd if=/dev/zero of=/tmp/swapfile bs=1M count=10240

/tmp/swapfile是我们创建的swap分区文件,可以充当swap分区,这个文件需要占用10240MB的空间,也就是10GB,可以根据硬盘的空间情况放在其他位置,我这里把它放在了/tmp文件夹下

#格式化分区

sudo mkswap /tmp/swapfile

#加载分区

sudo swapon /tmp/swapfile

步骤:回收swap分区

#卸载分区

sudo swapoff /tmp/swapfile

#删除swapfile

sudo rm /tmp/swapfile

如果分区在使用完毕后不再需要它,需要先卸载分区,才能删除,否则会报操作权限不足错误

注意:源码在编译后可能会占用10~15GB的硬盘空间,请确保你的硬盘空间足够

 

二、报debian/canonical-certs.pem错误

#在源代码根目录下vim打开.config文件

vim .config

找到CONFIG_SYSTEM_TRUSTED_KEYS,把CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"改成CONFIG_SYSTEM_TRUSTED_KEYS=""。

[可选]

将CONFIG_SYSTEM_REVOCATION_KEYS="debian/canonical-revoked-certs.pem"改成CONFIG_SYSTEM_REVOCATION_KEYS=""

 

三、编译vmlinux中出现vmlinux.o warning警告

......

LD vmlinux.o
vmlinux.o: warning: objtool: ibt_selftest+0x11: sibling call from callable instruction with modified stack frame
vmlinux.o: warning: objtool: ibt_selftest+0x1e: return with modified stack frame

......

这是GCC编译器版本过高产生的警告,可以无视。

 

四、出现bzImage错误

......

OBJCOPY arch/x86/boot/compressed/vmlinux.bin
RELOCS arch/x86/boot/compressed/vmlinux.relocs
ZSTD22 arch/x86/boot/compressed/vmlinux.bin.zst
/bin/sh: 1: zstd: not found
make[2]: *** [arch/x86/boot/compressed/Makefile:146: arch/x86/boot/compressed/vmlinux.bin.zst] Error 127
make[2]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.bin.zst'
make[1]: *** [arch/x86/boot/Makefile:116: arch/x86/boot/compressed/vmlinux] Error 2
make: *** [arch/x86/Makefile:283: bzImage] Error 2

......

 说明bzImage这个文件没有编译,使用make bzImage去编译生成这个文件

 

五、/bin/sh: 1: zstd: not found

在编译bzImage时可能会出现这个报错

......

ZSTD22 arch/x86/boot/compressed/vmlinux.bin.zst
/bin/sh: 1: zstd: not found
make[2]: *** [arch/x86/boot/compressed/Makefile:146: arch/x86/boot/compressed/vmlinux.bin.zst] Error 127
make[2]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.bin.zst'
make[1]: *** [arch/x86/boot/Makefile:116: arch/x86/boot/compressed/vmlinux] Error 2
make: *** [arch/x86/Makefile:283: bzImage] Error 2

你需要使用apt命令安装zstd这个包

sudo apt install zstd

另外,这个错误中同时报了一个127错误码,保险起见需要去安装C/C++的编译环境build-essential

sudo apt install build-essential

再次makeb zImage

然后得到成功的提示:

Kernel: arch/x86/boot/bzImage is ready (#3)

至此,成功完成bzImage的编译,再次make编译源码

 

六、init/version.c:54:1: fatal error: opening dependency file init/.version.o.d: Permission denied

这是因为没有权限的原因,使用sudo make即可解决

 

七、重启后出现error: the initial is too big报错

[可选]可能也会存在loading initial ramdisk的提示。这个提示可以用update-initramfs -c -k 6.2.0

上面的6.2.0是我编译的内核版本号,需要根据实际编译的内核版本去写,比如我可能编译5.4.2,那么这个命令就是update-initramfs -c -k 5.4.2了,这个命令不是必须的,只是以防报错,在下面的安装模块中也会执行命令,因此这个命令是不必要执行的。

使用以下命令去安装模块:

sudo make INSTALL_MOD_STRIP=1 modules_install

再次安装内核(sudo make install)即可,使用uname -r查看内核版本

 

八、BTF:.tmp_vmlinux.btf: pahole(pahole) is not available

原因:缺少dwarves软件包,使用包管理工具安装这个包即可。

apt install dwarves

 

posted on   TN-mo  阅读(1366)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

点击右上角即可分享
微信分享提示