linux kernel编译

zwlwf / 2024-10-14 / 原文

编译x86的kernel

export ARCH=x86_64
export CROSS_COMPILE=x86_64-linux-gnu-
make defconfig
make -j32

中间出现了libelf.h找不到, sudo apt-get install libelf-dev bc解决。

编译aarch64的kernel

export ARCH=x86_64
export CROSS_COMPILE=x86_64-linux-gnu-
make defconfig
make -j32

参考下面的说明可以编译一个external kernel
https://www.kernel.org/doc/html/latest/kbuild/modules.html

准备linux rootfs文件系统

debootstrap装x86 64时,arch给定amd64, 而不是x86/x86_64.

debootstrap --arch amd64 --foreign buster linux_rootfs_x86 http://mirrors.ustc.edu.cn/debian/
sudo chroot linux_rootfs_x86/ debootstrap/debootstrap --second-stage

装aarch64的系统,
debootstrap --arch arm64--foreign buster linux_rootfs_x86 http://mirrors.ustc.edu.cn/debian/