搬瓦工 VPS Ubuntu 16.04 手动升级内核开启 BBR 的方法

说起来你们可能不信,今天为了给昨天新买的搬瓦工的几台 VPS 安装个 BBR,折腾了一个多小时。之前的一键安装包在 Ubuntu 16.04 上突然不好使了,老是提示错误,不知道是个例还是普遍现象,在这里先分享一下手动升级内核开启 BBR 的方法。

话说回来,昨天补货我买了 5 台年付 18.79 美元的(相关链接),接下来会陆续搭建演示站点。

搬瓦工 VPS Ubuntu 16.04 手动升级内核开启 BBR 的方法插图

文章目录
隐藏
错误提示
手动升级内核
开启 BBR
检查、收尾

错误提示

当使用之前分享的一键安装包安装 BBR 时(搬瓦工安装 BBR 教程),总是提示下面的错误:

Selecting previously unselected package linux-image-4.14.36-041436-generic.
(Reading database ... 92043 files and directories currently installed.)
Preparing to unpack linux-image-4.14.36-i386.deb ...
Unpacking linux-image-4.14.36-041436-generic (4.14.36-041436.201804240906) ...
dpkg: dependency problems prevent configuration of linux-image-4.14.36-041436-generic:
 linux-image-4.14.36-041436-generic depends on linux-modules-4.14.36-041436-generic; however:
  Package linux-modules-4.14.36-041436-generic is not installed.

dpkg: error processing package linux-image-4.14.36-041436-generic (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-4.14.36-041436-generic
removed 'linux-image-4.14.36-i386.deb'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.14.36-041436-generic
Found linux image: /boot/vmlinuz-4.4.0-121-generic
Found initrd image: /boot/initrd.img-4.4.0-121-generic
Found linux image: /boot/vmlinuz-4.4.0-62-generic
Found initrd image: /boot/initrd.img-4.4.0-62-generic
done

尝试了好几个不同版本的内核,自动安装时都提示这个错误。网上搜了下并没有搜到这个问题,如果强行重启的话就是启动不起来了。于是只能尝试手动安装。

手动升级内核

下面先手动升级一下内核,我选择的是升级到 4.14,更多版本可以自己前往:

http://kernel.ubuntu.com/~kernel-ppa/mainline/

进行挑选。

下面直接复制我安装的整个过程,重要部分用粗体加粗以及添加了注释,注意查看。

第一步下载内核就不用多说了吧?比如我选的是 4.14,那么就在 http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14/ 挑选出 linux-image-4.14.0-041400-generic-xxxxx_amd64.deb(或者 i386,根据你操作系统是 64 位还是 32 位进行选择)。挑选完后复制链接,直接在 VPS 里 wget 即可(wget command not found?自己解决吧)。

然后开始安装。一共就两步:

安装内核:

dpkg -i linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb

更新 grub:

/usr/sbin/update-grub

如果提示错误,配置一下 dpkg:

dpkg --configure -a

详细步骤如下所示。

root@ubuntu:~# dpkg -i linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb // 换成你下载的对应的内核名称
Selecting previously unselected package linux-image-4.14.0-041400-generic.
(Reading database ... 64836 files and directories currently installed.)
Preparing to unpack linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb ...
Done.
Unpacking linux-image-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
dpkg: dependency problems prevent configuration of linux-image-4.14.0-041400-generic:
 linux-image-4.14.0-041400-generic depends on kmod; however:
  Package kmod is not configured yet.

dpkg: error processing package linux-image-4.14.0-041400-generic (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-4.14.0-041400-generic
root@ubuntu:~# dpkg --configure -a // 第一次安装提示失败,需要配置一下 dpkg
Setting up git-man (1:2.7.4-0ubuntu1.3) ...
 ......... 中间省略 ..........
17 added, 42 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for systemd (229-4ubuntu21.1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 linux-generic
root@ubuntu:~# dpkg -i linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb // 再次尝试安装
(Reading database ... 71021 files and directories currently installed.)
Preparing to unpack linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb ...
Done.
Unpacking linux-image-4.14.0-041400-generic (4.14.0-041400.201711122031) over (4.14.0-041400.201711122031) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
Setting up linux-image-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Not updating initrd symbolic links since we are being updated/reinstalled 
(4.14.0-041400.201711122031 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled 
(4.14.0-041400.201711122031 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
update-initramfs: Generating /boot/initrd.img-4.14.0-041400-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.14.0-041400-generic
Found initrd image: /boot/initrd.img-4.14.0-041400-generic
Found linux image: /boot/vmlinuz-4.4.0-121-generic
Found initrd image: /boot/initrd.img-4.4.0-121-generic
Found linux image: /boot/vmlinuz-4.4.0-62-generic
Found initrd image: /boot/initrd.img-4.4.0-62-generic
done
root@ubuntu:~# /usr/sbin/update-grub  //内核安装成功,更新 grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.14.0-041400-generic
Found initrd image: /boot/initrd.img-4.14.0-041400-generic
Found linux image: /boot/vmlinuz-4.4.0-121-generic
Found initrd image: /boot/initrd.img-4.4.0-121-generic
Found linux image: /boot/vmlinuz-4.4.0-62-generic
Found initrd image: /boot/initrd.img-4.4.0-62-generic
done

开启 BBR

内核升级完成后,重启一下,然后开启 BBR。

开启 BBR 一共需要这么几个命令:

sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
sysctl -p >/dev/null 2>&1

当然,如果你嫌麻烦,这时候也可以把之前那篇一键安装 BBR 的文章里的那个一键脚本拿过来运行一遍(传送门:搬瓦工 VPS 开启谷歌 BBR 教程),这时候因为已经升级完内核,那个脚本会自动帮你开启 BBR。

检查、收尾

然后就成功了,用 uname -r 检查一下内核版本,用 lsmod | grep bbr 看一下 bbr 是否已经开启,一般都没毛病。我安装完后 apt update 了一下提示我有问题,但是用 apt -f install 即可解决。

还没买年付 18.79 美元的新一代搬瓦工传家宝,就赶紧去买一台吧!直达链接:搬瓦工年付 18.79 美元传家宝方案

搬瓦工 VPS Ubuntu 16.04 手动升级内核开启 BBR 的方法插图1

未经允许不得转载:Bandwagonhost中文网 » 搬瓦工 VPS Ubuntu 16.04 手动升级内核开启 BBR 的方法

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注