以openkylin为例编译安装内核

  1. 从现有系统的/boot目录下找到带有config字样的配置文件

  2. 因为openkylin自带docker,所以这里使用容器编译

  3. openkylin实际上是Ubuntu focal 所以选择ubuntu:focal作为容器系统 同理 deepin、uos实际上是debian buster

  4. 下载你想要安装的内核版本

  5. 把上述这些东西所在的文件夹直接挂载给容器

  6. 解包linux-x.x.x

  7. 把准备好的配置文件放到文件夹里并重命名为.config

  8. 安装编译所需的全部依赖


# 首先把apt源文件中的deb-src注释全部打开

apt update

apt install -y libncurses-dev pkg-config wget git xz-utils make gcc flex bison dpkg-dev bc rsync kmod cpio libssl-dev

apt build-dep -y linux

  1. 将当前linux文件夹设置为代码仓库

git init

git add .

git config --global user.name "Your Name"

git config --global user.email "youremail@yourdomain.com"

git commit -m "1"

  1. 开始编译

make olddefconfig

scripts/config --disable DEBUG_INFO

scripts/config --enable MODULE_COMPRESS

make CCACHE_DISABLE=1 deb-pkg -j8

  1. 导出编译产物

linux-x.x.x同级目录下的deb包就是目标产物

导出到实体机安装

主要安装

linux-headers*

linux-image(不带有dbg字样)

两个包即可

  1. 安装

将deb包移动到实体机的/tmp目录下

执行


sudo apt install -d /tmp/*.deb

完成

2 个赞

官方的内核都比较老旧

标记,学习