2026-04-02 23:12:36 +08:00

69 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 回退Ubuntu Linux kernel
createTime: 2024/09/04 17:57:37
tags:
- ubuntu
categories:
- 随记
---
## 背景
前段时间 Ubuntu22.4 自动更新内核后nvidia 535.86 安装不上了,编译报错`ERROR: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol 'rcu_read_unlock_strict'`
大概有这么个公告:
> **Problem with 535 Nvidia drivers and 5.15.0-106 kernel**
> Recently, an ubuntu update to the 5.15.0-106 kernel produced the following error from the nvidia driver when it compiled the kernel module:
>
> ERROR: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol 'rcu_read_unlock_strict'
>
> We typically freeze our driver updates so that we can do them at planned downtimes the fix was to unhold the held nvidia-driver packages and upgrade to nvidia-driver-550
在 forum 上也确定了确实是内核更新带来的 bug所以简单粗暴回退内核更新尝试解决
## 回退 kernel
```bash
# 查看当前内核版本
uname -a
# 查看grub可选内核版本
grep menuentry /boot/grub/grub.cfg
```
输出类似下面这样:
> if [ x"${feature_menuentry_id}" = xy ]; then
> menuentry_id_option="--id"
> menuentry_id_option=""
> export menuentry_id_option
> menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-119-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-119-generic-advanced-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-119-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-119-generic-recovery-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-105-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-105-generic-advanced-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-105-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-105-generic-recovery-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-84-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-84-generic-advanced-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-84-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-84-generic-recovery-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-78-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-78-generic-advanced-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'Ubuntu, with Linux 5.15.0-78-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-78-generic-recovery-cdc0eb43-b3e9-4337-b245-bb62aeb7cff5' {
> menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
说明可选内核版本有`Ubuntu, with Linux 5.15.0-119-generic``Ubuntu, with Linux 5.15.0-105-generic``Ubuntu, with Linux 5.15.0-84-generic``Ubuntu, with Linux 5.15.0-78-generic`
```bash
# 查看nvidia驱动版本匹配
ls /var/lib/dkms/nvidia/
# 修改GRUB文件
sudo vi /etc/default/grub
```
修改`GRUB_DEFAULT=0``0`值为`"Advanced options for Ubuntu>合适的内核版本"`
```bash
# 更新grub
sudo update-grub
# 重启
sudo reboot
```