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
  • Use an extremely high number in the version of your kernel, like 9999 then it will install and be the top of the list, putting a hold on it with the command in the link below should stop it from being updated too. The process that did it is called apt the package manager. Ubuntu decided to upgrade the kernel most likely for security reasons and it was installed during an updating of the software on the machine. It told you new kernel was to be installed with all the other packages it listed in its output. https://askubuntu.com/questions/18654/how-to-prevent-updating-of-a-specific-package –  Feb 14 '21 at 17:39
  • Thanks. At the time I compiled about a month ago, this was my reason for selecting 1027.99 as the version #. So 1028 popping in was a frustration. Yeah I need to work on apt hold too – D1utz Feb 14 '21 at 18:11
  • The 1027.99 gets beat by 1028 every time for a version as it is .01 higher. –  Feb 14 '21 at 18:13
  • understood, but the big drawback of building a 1099 version right now is the hours of compiling. There seems to be a complete 1027 kernel still residing in my /boot folder, reactivating that or uninstalling 1028 would be preferred. In other words, ubuntu is doing something to preserve my old version in /boot but there is no obvious way/documention on "selecting from installed kernel versions" on raspi – D1utz Feb 14 '21 at 18:44
  • You are correct or I have never seen such a document, you want to build a 9999 version of it. That way Ubuntu will never get on top of you in the install version order, in Debian when I used to build my own kernels they called this setting an epoch, I think. A quick search says my memory servers me well, this page here explains some of it and the hold procedure. https://www.debian.org/releases/testing/ppc64el/release-notes/ch-upgrading.en.html –  Feb 14 '21 at 20:26

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.