1

I complied a custom ubuntu kernel for raspi and some update process auto-installed a newer kernel that I do not want to use. With the understanding that grub is not used on raspi, I'm struggling to understand how to select the older kernel. I started changing symlinks in /boot, but something is still missing. I suppose there might be a way to uninstall whatever kernel upgrade in apt, but I cant find the right info for that either. The kernel I want use is "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

my boot folder looks like this after some changes to the symlinks but this is not enough to make 1027 the active kernel. Note vmlinuz -> vmlinuz-5.4.0-1027-raspi but 1028 is still the active kernel. I suppose there might be a way to indicate the correct kernel in /firmware/usercfg.txt but I have not found it.

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

D1utz
  • 21

2 Answers2

1

Workaround:

  1. use apt to uninstall the new kernel that overwrote my custom kernel.
  2. reinstall custom kernel
    warning - deb files for custom kernel required
  3. put custom kernel on hold to prevent upgrade
# 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"

D1utz
  • 21
0

I don't know what is the proper way to do it but I know one that works. You need to put selected vmlinuz and initrd.img in /boot/firmware. After you reboot you'll be running chosen kernel version.