我为 raspi 编译了一个自定义的 ubuntu 内核,但某些更新过程自动安装了一个我不想使用的新内核。由于了解到 raspi 上不使用 grub,我很难理解如何选择旧内核。我开始更改 /boot 中的符号链接,但仍然缺少一些东西。我想可能有一种方法可以卸载 apt 中的任何内核升级,但我也找不到正确的信息。我想要使用的内核是“linux-image-5.4.0-1027-raspi”。
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=====================================-=============-============-=================================================
un linux-image <none> <none> (no description available)
rc linux-image-5.4.0-1015-raspi 5.4.0-1015.15 arm64 Linux kernel image for version 5.4.0 on ARMv8 SMP
rc linux-image-5.4.0-1026-raspi 5.4.0-1026.29 arm64 Linux kernel image for version 5.4.0 on ARMv8 SMP
ii linux-image-5.4.0-1027-raspi 5.4.0-1027.99 arm64 Linux kernel image for version 5.4.0 on ARMv8 SMP
ri linux-image-5.4.0-1028-raspi 5.4.0-1028.31 arm64 Linux kernel image for version 5.4.0 on ARMv8 SMP
ii linux-image-raspi 5.4.0.1028.63 arm64 Raspberry Pi Linux kernel image
在对符号链接进行一些更改后,我的启动文件夹看起来像这样,但这不足以使 1027 成为活动内核。请注意,vmlinuz -> vmlinuz-5.4.0-1027-raspi
但 1028 仍然是活动内核。我想可能有一种方法可以在 /firmware/usercfg.txt 中指示正确的内核,但我还没有找到它。
ubuntu@ubuntu:/boot$ ls -l
total 91476
-rw------- 1 root root 4175267 Jan 26 13:19 System.map-5.4.0-1027-raspi
-rw------- 1 root root 4165040 Jan 20 05:27 System.map-5.4.0-1028-raspi
-rw-r--r-- 1 root root 218901 Jan 26 13:19 config-5.4.0-1027-raspi
-rw-r--r-- 1 root root 218981 Jan 20 05:27 config-5.4.0-1028-raspi
lrwxrwxrwx 1 root root 43 Feb 14 10:15 dtb -> dtbs/5.4.0-1027-raspi/./bcm2711-rpi-4-b.dtb
lrwxrwxrwx 1 root root 43 Feb 14 10:15 dtb-5.4.0-1027-raspi -> dtbs/5.4.0-1027-raspi/./bcm2711-rpi-4-b.dtb
lrwxrwxrwx 1 root root 43 Jan 29 06:31 dtb-5.4.0-1028-raspi -> dtbs/5.4.0-1028-raspi/./bcm2711-rpi-4-b.dtb
drwxr-xr-x 7 root root 4096 Jan 29 06:31 dtbs
drwxr-xr-x 4 root root 4096 Dec 31 1969 firmware
lrwxrwxrwx 1 root root 27 Jan 29 06:29 initrd.img -> initrd.img-5.4.0-1027-raspi
-rw-r--r-- 1 root root 34052631 Feb 14 10:15 initrd.img-5.4.0-1027-raspi
-rw-r--r-- 1 root root 34092058 Jan 29 06:31 initrd.img-5.4.0-1028-raspi
lrwxrwxrwx 1 root root 27 Jan 29 06:29 initrd.img.1028 -> initrd.img-5.4.0-1028-raspi
lrwxrwxrwx 1 root root 30 Jan 22 08:21 initrd.img.bak -> initrd.img-5.4.0-1026.29-raspi
lrwxrwxrwx 1 root root 24 Jan 29 06:29 vmlinuz -> vmlinuz-5.4.0-1027-raspi
-rw------- 1 root root 8380579 Jan 26 13:19 vmlinuz-5.4.0-1027-raspi
-rw------- 1 root root 8342476 Jan 20 05:27 vmlinuz-5.4.0-1028-raspi
lrwxrwxrwx 1 root root 24 Jan 29 06:29 vmlinuz.1028 -> vmlinuz-5.4.0-1028-raspi
lrwxrwxrwx 1 root root 27 Jan 22 08:21 vmlinuz.bak -> vmlinuz-5.4.0-1026.29-raspi
答案1
解决方法:
- 使用 apt 卸载覆盖我的自定义内核的新内核。
- 重新安装自定义内核
警告 - 需要自定义内核的 deb 文件 - 暂停自定义内核以防止升级
# getting rid of auto-updated kernel
# version to uninstall = 1028
# review installed kernels:
apt list linux-image*raspi
# get detail on an installed kernel
apt show linux-image-5.4.0-1028-raspi
# remove the "wrong" new version
# NOTE YOU WILL GET A WARNING ABOUT REMOVING THE BOOT KERNEL
sudo apt remove linux-image-5.4.0-1028-raspi
# DO NOT REBOOT
# cd to location of my compiled kernel .deb files
# reference: kernel compile for ubuntu on pi
# https://askubuntu.com/questions/1238261/customizing-the-kernel-arm64-using-ubuntu-20-04-lts-on-a-raspberry-pi-4
cd ~/kbuild
# install my previously compiled custom kernel as per instruction for installing a newly compiled or recompiled kernel:
sudo dpkg -i *.deb
sync
sudo reboot
# put my kernel on "hold" status to prevent auto-update
echo "linux-image-5.4.0-1027-raspi hold" | sudo dpkg --set-selections
# review dpkg status setting for linux-image:
dpkg --get-selections | grep "linux-image"
答案2
我不知道正确的方法是什么,但我知道一个可行的方法。您需要将选定的 vmlinuz 和 initrd.img 放入 /boot/firmware。重启后,您将运行选定的内核版本。