很多VPS安装的Debian10不管是DD的还是自带的版本都是4.XX。虽然不影响使用,但是就是想升级到最新的内核看看情况。

备份数据

按自己需求来。阿里云、腾讯云、华为云可以先打个快照。其他云服务器或者VPS可以备份数据到本地。虽然此过程几乎无风险(有VNC用户)。但是也要照顾部分用户没有VNC的。那么如果挂掉就没办法恢复了。

添加软件源

有两种方法添加软件源

方法一

在SSH中直接输入代码,其中buster代表Debian版本。请按自己实际情况来。Debian8、9、10应该是都可以的。

echo -e "\ndeb https://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
apt-get update

方法二

宝塔中找到 “/etc/apt/source.list”,添加以下代码:

deb https://deb.debian.org/debian buster-backports main

Debian8用户请改archive源。

注意

这步骤有个小坑,debian10可能会提示如下所示错误

Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification.
No system certificates available. Try installing ca-certificates.

这是证书https验证不了报错,可以把https改成http使用,也可以安装证书验证组件

安装证书组件

apt install apt-transport-https ca-certificates

或者修改为http使用

echo -e "\ndeb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
apt-get update

升级内核

使用root账户ssh输入以下命令,先升级下软件列表

apt-get update

再升级内核

apt install -t buster-backports linux-image-cloud-amd64 linux-headers-cloud-amd64

执行后会升级内核到最新cloud版。优点就是占用内存少。

更新Grub

更新Grub,输入如下命令:

update-grub

实际你安装的时候可能更新。更新完后,除了内存占用,完全感觉不出区别。据说Linux Kernel 5.5后的版本BBR会有所区别。你可以自己体验一下。

删除旧内核

dpkg --get-selections | grep linux
apt autoremove --purge linux-image-4.19.0-5-amd64
apt autoremove
apt autoclean