567899.xyz

Ubuntu & Debian & CentOS手动编译安装 TCP BBR v2 Alpha/Preview 内核

567899.xyz bbr2CentOSUbuntuDebiantcp

TCP BBR v2 alpha: https://github.com/google/bbr/tree/v2alpha

Ubuntu & Debian 环境依赖

apt-get update
apt install -y build-essential libncurses5-dev
apt -y build-dep linux
apt install -y git 

(可选)如提示错误E: You must put some ‘source’ URIs in your sources.list解决方法如下

sed -i 's/#deb-src/deb-src/g' /etc/apt/sources.list
sed -i 's/# deb-src/deb-src/g' /etc/apt/sources.list
apt-get update

编译内核

# 下载源码
git clone -o google-bbr -b v2alpha  https://github.com/google/bbr.git
cd bbr
# 禁用签名调试
scripts/config --disable MODULE_SIG
scripts/config --disable DEBUG_INFO
# 配置tcp bbr2选项
make menuconfig

依次进入Networking support ---> Networking options ---> TCP: advanced congestion control ---> BBR2 TCP 按空格键在前面标记<M> 其它选项保持默认即可.(也可以按/ 在搜索框输入bbr2回车根据查询结果,按数字键 1 进入BBR2 TCP配置页面按空格键标记<M> BBR2 TCP )

开始编译

screen -S kernel  # 新建一个会话
make -jN deb-pkg  # N 为线程数

编译完成后 /root 目录下生成以下文件

linux-5.2.0-rc3+_5.2.0-rc3+-1.diff.gz
linux-5.2.0-rc3+_5.2.0-rc3+-1.dsc
linux-5.2.0-rc3+_5.2.0-rc3+-1_amd64.buildinfo
linux-5.2.0-rc3+_5.2.0-rc3+-1_amd64.changes
linux-5.2.0-rc3+_5.2.0-rc3+.orig.tar.gz
linux-headers-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb
linux-image-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb
linux-libc-dev_5.2.0-rc3+-1_amd64.deb

如果你不想自己编译也可以下载本站编译好的内核,编译时间:2019-10-22

linux-headers-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb

linux-image-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb

linux-libc-dev_5.2.0-rc3+-1_amd64.deb

安装 v2alpha 内核

下载后缀为*.deb的3个文件,以 Debian 9 64-bit 为例

dpkg -i linux-headers-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb
dpkg -i linux-image-5.2.0-rc3+_5.2.0-rc3+-1_amd64.deb
dpkg -i linux-libc-dev_5.2.0-rc3+-1_amd64.deb
update-grub
reboot

开启 bbr2

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr2" >> /etc/sysctl.conf
echo "net.ipv4.tcp_ecn = 1" >> /etc/sysctl.conf # 开启ECN (可选)
sysctl -p

查看是否开启 bbr2

sysctl net.ipv4.tcp_available_congestion_control
# net.ipv4.tcp_available_congestion_control = reno cubic bbr2
lsmod | grep bbr
# tcp_bbr2               40960  1

删除多余旧内核

首先查询当前我们使用的是内核是那个版本别删错了。

uname -a

查询系统中装了多少内核

dpkg --get-selections|grep linux

多余的内核可以通过命令删除 需要删除header和image

apt-get purge linux-image-*.*.*-**       # *号用你想删除的实际情况改写
apt-get purge linux-headers-*.*.*-**     # *号用你想删除的实际情况改写

CentOS安装启用bbr

wget https://567899.xyz/uploads/kernel-5.2.0_rc3+-1.x86_64.rpm
wget https://567899.xyz/uploads/kernel-headers-5.2.0_rc3+-1.x86_64.rpm
yum -y localinstall *
grub2-set-default 0
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr2" >> /etc/sysctl.conf
echo "net.ipv4.tcp_ecn = 1" >> /etc/sysctl.conf   # 开启ecn (可选)
sysctl -p
rm kernel-5.2.0_rc3+-1.x86_64.rpm
rm kernel-headers-5.2.0_rc3+-1.x86_64.rpm
reboot

查询系统中全部的内核

rpm -qa | grep kernel

CentOS 清除旧内核

yum remove kernel-3.10.0-693.21.1.el7.x86_64  #替换自己的内核名

Linux kernel 5.4-rc6 make on 1120 2019

wget https://github.com/hvvy/bbr/releases/download/0.1.1/linux-headers-5.4.0-rc6_5.4.0-rc6-1_amd64.deb
wget https://github.com/hvvy/bbr/releases/download/0.1.1/linux-image-5.4.0-rc6_5.4.0-rc6-1_amd64.deb
wget https://github.com/hvvy/bbr/releases/download/0.1.1/linux-libc-dev_5.4.0-rc6-1_amd64.deb
dpkg -i linux-headers-5.4.0-rc6_5.4.0-rc6-1_amd64.deb
dpkg -i linux-image-5.4.0-rc6_5.4.0-rc6-1_amd64.deb
dpkg -i linux-libc-dev_5.4.0-rc6-1_amd64.deb
update-grub
reboot
567899.xyz
记录折腾中的点点滴滴