【Linux】如何降低/升级Linux内核版本

有些驱动会依赖Linux系统内核版本,如果Linux内核进行了升级,会导致驱动失效。这时候就需要回滚或降级Linux系统内核。操作方法如下,亲测有效:

#查询当前系统内核是否设为hold

dpkg --get-selections | grep hold

#如果是hold,需要将当前系统设为unhold

apt-mark unhold linux-headers-5.15.0-117-generic

apt-mark unhold linux-image-5.15.0-117-generic

apt-mark unhold linux-modules-5.15.0-117-generic

#打开系统文件,将里面的1设为0,表示允许修改系统文件配置

vim /etc/apt/apt.conf.d/10periodic -->将里面的1全设为0

vim /etc/apt/apt.conf.d/20auto-upgrades -->将里面的1全设为0

root@c:~# cat /etc/apt/apt.conf.d/10periodic

APT::Periodic::Update-Package-Lists "1";

APT::Periodic::Download-Upgradeable-Packages "0";

APT::Periodic::AutocleanInterval "0";

root@c:~# cat /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Update-Package-Lists "0";

APT::Periodic::Unattended-Upgrade "0";

#查询当前一共装了多少个版本的系统内核

dpkg --get-selections | grep linux-image

#查看可降级的内核版本

dpkg --list | grep linux-image

#降级内核命令,从117降到116,重新安装116

sudo apt-get install linux-image-5.15.0-116-generic

sudo apt-get install linux-headers-5.15.0-116-generic

sudo apt-get install linux-module-5.15.0-116-generic

# 修改当前系统中内核的启动顺序

ubuntu@ubuntu:~$ grep menuentry /boot/grub/grub.cfg

# 修改内核启动顺序

sudo vim /etc/default/grub

第一步:GRUB_DEFAULT=0

第二步: GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.4.0-120-generic"

# 执行update-grub 命令更新启动配置

sudo update-grub

# 重启系统后查看内核版本

ubuntu@ubuntu:~$ uname -r

5.15.0-116-generic

修改成功!

#如果不希望该版本再自动升级,可锁住

vim /etc/apt/apt.conf.d/10periodic -->将里面的0全设为1

vim /etc/apt/apt.conf.d/20auto-upgrades -->将里面的0全设为1

apt-mark hold linux-headers-5.15.0-116-generic --> 禁止内核升级

apt-mark hold linux-image-5.15.0-116-generic --> 禁止内核升级

apt-mark hold linux-modules-5.15.0-116-generic --> 禁止内核升级

dpkg --get-selections | grep hold -->查询内核是否锁住不允许升级

如果希望升级内核

1. 查看内核是否hold

dpkg --get-selections | grep hold

2. 查看可升级的内核

apt update 查看升级

apt-cache search linux-image

3. 安装想要的内核版本

apt install linux-image-5.15.0-116-generic

4. 更新grub

# 修改内核启动顺序

sudo vim /etc/default/grub

第一步:GRUB_DEFAULT=0

第二步: GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.15.0-116-generic"

# 执行update-grub 命令更新启动配置

sudo update-grub

5. reboot即可

在flash CS5中的帧之间插入帧
电脑键盘错乱了怎么调回来 4个步骤轻松解决