Reference:
sudo apt-get install libncurses5-dev gcc make git exuberant-ctags bc libssl-dev flex bison libelf-dev rsyncTry to build the kernel on a host with similar kernel versions
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.86.tar.xz
tar xvf linux-5.4.86.tar.xzIf the host kernel version is similar to the built kernel, then copy the host build config:
cp /boot/config-`uname -r`* linux-5.4.86/.config Otherwise, generate a basic config:
cd linux-5.4.86
make x86_64_defconfig
make kvm_guest.config If you are building the kernel to run on a bare-metal machine, you may also need to disable some key signing-related configs:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
scripts/config --disable SECURITY_LOCKDOWN_LSM
scripts/config --disable MODULE_SIG
scripts/config --disable MODULE_SIG_ALLIf the build script asks to customize other configs during the initial compilation stage, just press Enter to choose default for all other configs.
make -j16 Resolve BTF: .tmp_vmlinux.btf: pahole (pahole) is not available Failed to generate BTF for vmlinux
Attempts to compile a more recent version of Linux may run into an error stating pahole is not available. To avoid this compilation error, use sudo apt-get install dwarves to install the missing package.
Alternatively, the error can also be avoided by disabling BPF Type Format so pahole won't be needed. In the kernel config, run scripts/config --disable CONFIG_DEBUG_INFO_BTF to disable BPF Type Format.
make -j16 bindeb-pkg