下载最新版内核源码⌗

目前最新内核版本为v5.16,可以从Github下载

git clone --depth 1 --branch v5.16 git@github.com:torvalds/linux.git

国内可以从Gitee的镜像仓库下载 https://gitee.com/mirrors/linux_old1/tree/v5.16/

git clone --depth 1 --branch v5.16 git@gitee.com:mirrors/linux_old1.git

安装依赖⌗

sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison

配置内核⌗

可以从当前机器上拷贝一份.config文件,然后再更新配置

cp "/boot/config-$(uname -r)" .config  # 复制
make oldconfig  # 更新配置

或者直接生成的新的默认配置

make defconfig

编译内核⌗

make -j4

耗时大约15分钟,编译的过程会输出到控制台,走完整个流程最后会输出

  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Kernel: arch/x86/boot/bzImage is ready  (#1)

成功构建arch/<arch>/boot/bzImage镜像文件,我这里<arch>是x86。

安装内核⌗

sudo make modules_install
sudo make install

参数资料⌗