Ubuntu 系统的内核升级的简单方法。本篇以 Ubuntu 20.04 为例,所有命令均以 root 用户运行。

下载最新内核

1
2
3
4
5
6
7
8
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.10/amd64/linux-headers-5.16.10-051610_5.16.10-051610.202202161442_all.deb

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.10/amd64/linux-headers-5.16.10-051610-generic_5.16.10-051610.202202161442_amd64.deb

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.10/amd64/linux-image-unsigned-5.16.10-051610-generic_5.16.10-051610.202202161442_amd64.deb


wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.16.10/amd64/linux-modules-5.16.10-051610-generic_5.16.10-051610.202202161442_amd64.deb

安装内核

1
dpkg -i *.deb

安装完成后需要重启

1
shutdown -r now

卸载旧内核

查看所有已经安装的内核和头文件

1
2
dpkg --list | grep linux-image
dpkg --list | grep linux-headers

卸载旧内核(注意一定要有一个内核可以使用)

1
2
apt purge linux-image-xxx
apt purge linux-headers-xx

关闭内核自动更新

1
apt-mark hold linux-image-generic linux-headers-generic

打开内核自动更新

1
apt-mark unhold linux-image-generic linux-headers-generic

查看内核版本

1
2
3
4
5
uname -r
# or
uname -rs
# or
uname -a

参考链接

  1. How to upgrade Linux Kernel on Ubuntu 20.04 to 5.16 Release
  2. How to upgrade Ubuntu to 22.04 and kernel to 5.16
  3. Ubuntu内核(更新和卸载内核、取消自动更新)