目前VPS商家提供的Debian 10系统基本上都是4.19.x.x的内核版本,站长本着用新不用旧的原则,在初次部署环境的时候,总是忍不住将系统内核版本升级到比较新的版本。
1、查看系统内核版本
uname -r
站长用于演示的这台Debian 10系统的VPS原始内核版本为:4.19.0-5-amd64
2、添加Debian官方 buster-backports 源
deb http://deb.debian.org/debian buster-backports main
编辑nano /etc/apt/sources.list,站长用nano编辑演示,默认如下图所示(有些商家默认有buster-backports源的,则略过):
将 buster-backports 源添加进去,然后按Ctrl+X退出;
这里会提示保存,输入Y并回车;
直接按回车确认将buster-backports源写入,
3、安装官方最新5.1x.x内核
先更新系统,命令如下:
apt update
3.1、如果在apt update之后报错,Err:4 http://deb.debian.org/debian buster-backports InRelease
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131
root@hostcsr.com:~# apt update -y Hit:1 http://security.debian.org/debian-security buster/updates InRelease Hit:2 http://deb.debian.org/debian buster InRelease Hit:3 http://deb.debian.org/debian buster-updates InRelease Get:4 http://deb.debian.org/debian buster-backports InRelease [51.4 kB] Err:4 http://deb.debian.org/debian buster-backports InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 Reading package lists... Done W: GPG error: http://deb.debian.org/debian buster-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131 E: The repository 'http://deb.debian.org/debian buster-backports InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
3.1.1、先安装debian-archive-keyring,再update即可。
apt-get install debian-archive-keyring apt update
3.2、如果在apt update之后报错:Err:5 http://deb.debian.org/debian buster-backports Release
root@hostcsr.com:~# apt update -y Hit:1 http://security.debian.org/debian-security buster/updates InRelease Hit:2 http://deb.debian.org/debian buster InRelease Hit:3 http://deb.debian.org/debian buster-updates InRelease Ign:4 http://deb.debian.org/debian buster-backports InRelease Err:5 http://deb.debian.org/debian buster-backports Release 404 Not Found [IP: 146.75.94.132 80] Reading package lists... Done E: The repository 'http://deb.debian.org/debian buster-backports Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
3.2.1、将 buster-backports 源从http://deb.debian.org/debian 切换到 http://archive.debian.org/debian 即可。
修改前:
deb http://deb.debian.org/debian buster-backports main
修改后:
deb http://archive.debian.org/debian buster-backports main
安装最新内核
apt install -t buster-backports linux-image-cloud-amd64 linux-headers-cloud-amd64
更新启动内核版本
update-grub
重启系统
reboot
4、卸载旧内核版本
输入uname -r
即可看到内核版本已经是5.10.0-0.bpo.7-cloud-amd64
;输入以下命令查看当前系统已经安装的内核版本;
dpkg --list | grep linux-image
使用apt purge
命令卸载旧的内核版本(按实际卸载的内核版本修改命令):
apt purge linux-image-4.19.0-5-amd64
输入以下命令查看当前系统已经安装的内核头文件;
dpkg --list | grep linux-headers
如果有4.19.x.x的内核头文件,也可以使用apt purge
命令卸载,命令如下(按实际卸载的内核头文件版本修改命令):
apt purge linux-headers-4.19.0-5-amd64
最后再动更新一下启动内核版本,可以看到,只剩下5.10.0-0.bpo.7-cloud-amd64
了。
update-grub
搞定!收工!……等等,好像还没完呢,查看下方这篇文章开启BBR才算真正搞定!