无法用补丁编译内核

无法用补丁编译内核

我正在尝试使用自定义补丁构建 ubuntu 5.3.0 内核。我下载了源代码并使用以下方法添加了补丁

patch -p1 < patch_name.patch

并使用进行配置

make config

然后我使用

make -j6

这给了我 vmlinux 和 vmlinux.o 文件。我不知道如何使用它们,所以我尝试将内核制作成 .deb 文件。我使用了

make deb-pkg

fakeroot make-kpkg -j N --initrd --append-to-version=my-very-own-kernel kernel-image kernel-headers

make bindeb-pkg

但是编译整个内核后,所有这些都给我同样的错误。

/bin/sh: 1: lz4c: not found
arch/x86/boot/compressed/Makefile:146: recipe for target 'arch/x86/boot/compressed/vmlinux.bin.lz4' failed
make[3]: *** [arch/x86/boot/compressed/vmlinux.bin.lz4] Error 127
make[3]: *** Deleting file 'arch/x86/boot/compressed/vmlinux.bin.lz4'
make[3]: *** Waiting for unfinished jobs....
arch/x86/boot/Makefile:112: recipe for target 'arch/x86/boot/compressed/vmlinux' failed
make[2]: *** [arch/x86/boot/compressed/vmlinux] Error 2
arch/x86/Makefile:284: recipe for target 'bzImage' failed
make[1]: *** [bzImage] Error 2
make[1]: Leaving directory '/home/beebop/Downloads/linux-hwe-edge-5.3.0'
debian/ruleset/targets/common.mk:295: recipe for target 'debian/stamp/build/kernel' failed
make: *** [debian/stamp/build/kernel] Error 2

我该如何编译 .deb 包,如果不能,是否与 vmlinux 和 vmlinux.o 文件有关?

答案1

在 Ubuntu 内核配置中默认使用 LZ4 压缩的改变相对较新。一些较旧的 Ubuntu 版本不仅默认没有安装与 LZ4 相关的工具,而且这些工具实际上不可用。

将压缩方法改回gzip:方法一:

scripts/config --disable KERNEL_LZ4
scripts/config --enable KERNEL_GZIP

方法 2:手动对内核配置进行以下更改:

改变这个:

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
# CONFIG_COMPILE_TEST is not set
# CONFIG_HEADER_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
# CONFIG_KERNEL_GZIP is not set
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
CONFIG_KERNEL_LZ4=y

对此:

#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
# CONFIG_COMPILE_TEST is not set
# CONFIG_HEADER_TEST is not set
CONFIG_LOCALVERSION=""
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_HAVE_KERNEL_LZ4=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_BZIP2 is not set
# CONFIG_KERNEL_LZMA is not set
# CONFIG_KERNEL_XZ is not set
# CONFIG_KERNEL_LZO is not set
# CONFIG_KERNEL_LZ4 is not set

注意:根据默认的 Ubuntu 内核设置,包含调试信息大约需要两倍的编译时间。建议禁用:

scripts/config --disable DEBUG_INFO

哪个应该这样做:

doug@s15:~/temp-k-git/linux$ scripts/diffconfig .config-5.4.0-050400-lowlatency .config
 DEBUG_INFO y -> n
doug@s15:~/temp-k-git/linux$ diff .config-5.4.0-050400-lowlatency .config
10144c10144
< CONFIG_DEBUG_INFO=y
---
> # CONFIG_DEBUG_INFO is not set

仅安装生成的标题文件(~12 兆字节)和图像文件(~60 兆字节)。

答案2

/bin/sh: 1: lz4c: not found
kernel/4.14/arch/x86/boot/compressed/Makefile:141: recipe for target 'arch/x86/boot/compressed/vmlinux.bin.lz4' failed 4:14

解决方案:[我要做的就是安装缺少的库] sudo apt-get install liblz4-tool

相关内容