- ccache: enable depend mode (skip the preprocessor on ~75k compiler calls) and add BASEDIR/NOHASHDIR/SLOPPINESS as insurance against false misses from build-path or build-macro churn. ccache -s already shows 99.99% direct hits, so this trims per-call overhead, not a broken cache. MAXSIZE stays 8G (only ~1G used). - deps: drop dwarves + libdw-dev. pahole only runs with CONFIG_DEBUG_INFO_BTF, but the build forces DEBUG_INFO_NONE, so they were never used. - config: disable MODULE_COMPRESS/MODULE_DECOMPRESS for both arches. arm64 alone shipped zstd module compression, running a zstd pass over ~8000 .ko every build for no gain (the .deb is already compressed by KDEB_COMPRESS); x86_64 never did. Keeps the two arches in sync. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
BBRv3 内核安装脚本
一个用于 Debian/Ubuntu VPS 的 BBRv3 内核分发方案。内核 .deb 包发布到本仓库自建 Gitea 的 Debian package registry(apt 源)。安装脚本会自动识别架构、配置 apt 源并安装 linux-image-bbrv3 meta-package,之后 sudo apt upgrade 即可自动跟随最新 stable 内核(旧内核保留以便回退)。内核默认启用 BBR 拥塞控制并内置 sch_cake;随包安装的 bbrv3-config 会写入 /etc/sysctl.d/99-bbrv3.conf,把默认队列算法设为 cake 并开启 ECN(net.ipv4.tcp_ecn=1),安装并重启后 BBR + CAKE + ECN 自动生效。
脚本入口:
bash <(curl -fsSL https://git.chilldove.com/icePigeon/linux-kernel-bbrv3/raw/branch/main/install.sh)
支持环境
| 项目 | 要求 |
|---|---|
| 最低支持系统 | Ubuntu 24.04+ / Debian 12+ |
| 包管理器 | apt-get |
| 架构 | x86_64 / aarch64 |
| 引导方式 | 建议使用 GRUB |
| 使用场景 | VPS / 云服务器 / 独立服务器 |
不建议在树莓派、NanoPi 等依赖 U-Boot 或厂商定制内核链路的设备上使用。此类设备的内核安装和启动流程通常与通用 Debian/Ubuntu VPS 不一致。
Debian testing/unstable 如缺少 VERSION_ID,脚本会按 VERSION_CODENAME 识别 bookworm、trixie、forky 和 sid。Alpine 等非 Debian 系统不支持安装本项目内核包(产物是 .deb,依赖 Debian/Ubuntu 的包管理与内核安装链路)。
本项目内核主线为 Linux 7.x。安装内核时脚本会按最低支持系统拦截过旧环境,避免因用户态、initramfs 或引导链路过旧导致启动失败或 kernel panic。
菜单功能
运行脚本后进入交互菜单:
1. 安装或更新 BBR v3 内核(最新版,apt 源自动跟随)
2. 安装指定版本
3. 检查 BBR v3 状态
4. 卸载 BBR v3 内核
内核与 BBR 策略
本项目的构建目标是:
BBRv3 补丁固定,内核自动跟随 kernel.org stable 的小版本更新。
BBR 实现不会在自动构建时偷偷更新;自动更新的是 Linux stable 内核的小版本。
追踪的是成熟 stable,而非 mainline。 一个新系列(如 7.1)刚发布时,kernel.org 的 “latest stable” 会瞬间等于 “latest mainline”——那其实还是尖端,不是经过 .z 打磨的 stable。因此构建脚本(scripts/select-stable-kernel.sh)只在满足以下全部条件的版本里取最高:
- 是带三段点号的点版本
X.Y.Z(排除刚发布、仅显示为X.Y的新系列); - 系列
X.Y严格低于当前 mainline(排除仍等于 mainline 的系列); - 仓库存在对应的
patches/bbrv3-linux-X.Y.patch。
当前 patch:
patches/bbrv3-linux-7.0.patch # linux-7.0.y
patches/bbrv3-linux-7.1.patch # linux-7.1.y
同系列小版本更新自动复用同一 patch(如 7.0.11 -> 7.0.12)。等新系列出了点版本、且 mainline 前移到再下一个系列,构建会自动接棒到新系列(前提是其 patch 已就位)。
安装最新版
运行脚本后选择:
1. 安装或更新 BBR v3 内核(最新版)
脚本会:
- 检查系统是否为 Debian/Ubuntu,架构是否为
x86_64或aarch64,并拦截过旧系统。 - 配置 apt 源:导入 registry 签名公钥到
/etc/apt/keyrings/,写入/etc/apt/sources.list.d/bbrv3.list。 apt-get install linux-image-bbrv3安装/升级到最新 stable(旧内核保留以便回退)。- 提示是否重启。
之后无需再跑脚本,直接 sudo apt update && sudo apt upgrade 即可跟随最新内核。不希望内核被 apt upgrade 自动更换时:
sudo apt-mark hold linux-image-bbrv3 # 钉死,停止自动跟随
sudo apt-mark unhold linux-image-bbrv3 # 解钉,恢复自动跟随
如果 registry 为私有或拉取签名公钥受限,可先设置 token 再运行:
export GITEA_TOKEN=你的 Gitea Token
bash <(curl -fsSL https://git.chilldove.com/icePigeon/linux-kernel-bbrv3/raw/branch/main/install.sh)
安装指定版本
运行脚本后选择:
2. 安装指定版本
脚本会列出 apt 源中可用的内核包并按编号安装;装完可选择 apt-mark hold 钉死,避免被 apt upgrade 自动更换。
内核包名格式:
linux-image-7.0.12-bbrv3
也可手动安装:sudo apt install linux-image-7.0.12-bbrv3。
手动配置 apt 源(不想用脚本)
sudo install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://git.chilldove.com/api/packages/icePigeon/debian/repository.key \
| sudo tee /etc/apt/keyrings/gitea-icePigeon.asc > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/gitea-icePigeon.asc] https://git.chilldove.com/api/packages/icePigeon/debian stable main" \
| sudo tee /etc/apt/sources.list.d/bbrv3.list > /dev/null
sudo apt update
sudo apt install linux-image-bbrv3
装完按需 sudo reboot。bbrv3-config 写入的 cake 默认队列需重启进新内核后才生效。
检查 BBRv3 状态
运行脚本后选择:
3. 检查 BBR v3 状态
脚本会检查:
tcp_bbr模块版本是否为3。- 当前 TCP 拥塞控制算法是否为
bbr。 - 当前默认队列算法是否为
cake。
也可以手动检查:
uname -r
sysctl net.ipv4.tcp_congestion_control
sysctl net.core.default_qdisc
sysctl net.ipv4.tcp_ecn
modinfo tcp_bbr 2>/dev/null | grep '^version:'
卸载
运行脚本后选择:
4. 卸载 BBR v3 内核
脚本会卸载由本项目安装的内核包(linux-image-*-bbrv3 与 meta 包 linux-image-bbrv3)及 bbrv3-config(purge 时带走 /etc/sysctl.d/99-bbrv3.conf),并移除 apt 源 /etc/apt/sources.list.d/bbrv3.list 与签名公钥;引导由内核包卸载钩子自动更新。卸载后建议重启。
内核包来源
.deb 内核包由 Gitea Actions 构建并发布到本仓库自建 Gitea 的 Debian package registry,提供 amd64 与 arm64 两种标准 BBRv3 内核(arm64 在同一台 x86_64 runner 上交叉编译)。一行 apt 源同时服务两种架构,apt 按本机架构自动取包。
构建流程会:
- 用
scripts/select-stable-kernel.sh选定要追踪的 stable 版本(见上文「内核与 BBR 策略」)。 - 下载
gregkh/linux对应 stable 分支,应用仓库内固定 BBRv3 patch。 - 默认启用 BBR,并把
sch_cake编入内核(=y);bbrv3-config包据此把默认队列设为 cake。 - 构建
linux-image-bbrv3(meta,跟随最新)与bbrv3-config(sysctl 配置)两个辅助包。 - 关闭 debug info,拒绝发布
*-dbg*.deb/*-dbgsym*.deb;不发布linux-libc-dev(避免覆盖发行版头文件)。 - 发布到 registry 的
stable/main,已存在的版本会跳过。
构建不会自动更新 BBR patch 本身。
发布所需:CI 配置一个有 write:package 权限的 PKG_TOKEN secret;Gitea 实例需启用 Packages → Debian registry。若 registry 前面有 CDN/反代对上传请求体设限(如 Cloudflare 免费/Pro 版 100 MB 上限),内核镜像 .deb(>100 MB)会在边缘被 413 拒绝——把 Gitea 源站地址(CDN 背后主机的 IP)配成 Gitea 仓库变量 PKG_ORIGIN_IP,发布步骤会用 curl --resolve 把上传直连源站、绕过 CDN(SNI/Host 不变,证书与包路由不受影响)。源站本身不受此限。
免责声明
内核升级有风险。安装前建议确认 VPS 控制台、救援模式或旧内核启动项可用。使用本项目构建或安装的内核造成的系统启动失败、网络异常或数据损失,由使用者自行承担。