4

I use Pop OS 20.04 and recently the kernel was upgraded and it caused some issues so I had to switch back to my previous kernel version. (More specifically, the kernel was upgraded to v5.16, and I had to revert back to v5.15 due to issues with some old versions of ElasticSearch).

As you might know, Pop OS uses systemd-boot, and a few months ago I used the systemd boot-menu to select the old-kernel as the default boot option. All was fine again, until a few days ago I noticed that the system was booted with kernel v5.16! I double checked the systemd boot-menu and it was still set to boot with the old kernel option! My guess is that the old kernel option was upgraded and switched to v5.16 which is not desirable!

Unfortunately in contrast to grub, it seems that systemd-boot tries to over-simplify things and doesn't show explicit kernel versions to select from!

So I searched for other options to change the default boot kernel and all I found was this article. So I used the following command to change my default kernel option:

me@pop-os:~$ sudo kernelstub -v -l -k /boot/vmlinuz-5.15.23-76051523-generic -i /boot/initrd.img-5.15.23-76051523-generic
kernelstub.Config    : INFO     Looking for configuration...
kernelstub           : INFO     System information: 

    OS:..................Pop!_OS 20.04
    Root partition:....../dev/sda3
    ESP Path:............/boot/efi
    ESP Partition:......./dev/sda1
    ESP Partition #:.....1
    NVRAM entry #:.......-1
    Boot Variable #:.....0000
    Kernel Boot Options:.quiet loglevel=0 systemd.show_status=false splash
    Kernel Image Path:.../boot/vmlinuz-5.15.23-76051523-generic
    Initrd Image Path:.../boot/initrd.img-5.15.23-76051523-generic
    Force-overwrite:.....False

kernelstub.Installer : INFO     Copying Kernel into ESP
kernelstub.Installer : INFO     Copying initrd.img into ESP
kernelstub.Installer : INFO     Setting up loader.conf configuration
kernelstub.Installer : INFO     Making entry file for Pop!_OS
kernelstub.Installer : INFO     Backing up old kernel
kernelstub.Installer : INFO     Making entry file for Pop!_OS

me@pop-os:~$ echo $?
0

As you can see from above, the command runs successfully with exit code 0; but it doesn't take effect! When I double check the output from kernelstub it's still the same as before!

me@pop-os:~$ sudo kernelstub -p
kernelstub.Config    : INFO     Looking for configuration...
kernelstub           : INFO     System information: 

    OS:..................Pop!_OS 20.04
    Root partition:....../dev/sda3
    ESP Path:............/boot/efi
    ESP Partition:......./dev/sda1
    ESP Partition #:.....1
    NVRAM entry #:.......-1
    Boot Variable #:.....0000
    Kernel Boot Options:.quiet loglevel=0 systemd.show_status=false splash
    Kernel Image Path:.../boot/vmlinuz-5.17.5-76051705-generic
    Initrd Image Path:.../boot/initrd.img-5.17.5-76051705-generic
    Force-overwrite:.....False

kernelstub           : INFO     Configuration details: 

   ESP Location:................../boot/efi
   Management Mode:...............True
   Install Loader configuration:..True
   Configuration version:.........3

Here are the kernels I have installed on my system:

me@pop-os:~$ dpkg --list | grep linux-image | grep ii
ii  linux-image-5.15.23-76051523-generic  Linux kernel image for version 5.15.23 on 64 bit x86 SMP
ii  linux-image-5.16.19-76051619-generic  Linux kernel image for version 5.16.19 on 64 bit x86 SMP
ii  linux-image-5.17.5-76051705-generic   Linux kernel image for version 5.17.5 on 64 bit x86 SMP
ii  linux-image-generic                   Generic Linux kernel image

UPDATE: Based on answer from @telcoM, here is the output of ‍‍bootctl list:

me@pop-os:~$ sudo bootctl list
Boot Loader Entries:
        title: Pop!_OS (Pop_OS-current.conf)
           id: Pop_OS-current.conf
       source: /boot/efi/loader/entries/Pop_OS-current.conf
        linux: /EFI/Pop_OS-4574dd5b-40ad-462f-bfbe-22676dd09bdc/vmlinuz.efi
       initrd: /EFI/Pop_OS-4574dd5b-40ad-462f-bfbe-22676dd09bdc/initrd.img
      options: root=UUID=4574dd5b-40ad-462f-bfbe-22676dd09bdc ro quiet loglevel=0 systemd.show_status=false splash

        title: Pop!_OS (Pop_OS-oldkern.conf) (default)
           id: Pop_OS-oldkern.conf
       source: /boot/efi/loader/entries/Pop_OS-oldkern.conf
        linux: /EFI/Pop_OS-4574dd5b-40ad-462f-bfbe-22676dd09bdc/vmlinuz-previous.efi
       initrd: /EFI/Pop_OS-4574dd5b-40ad-462f-bfbe-22676dd09bdc/initrd.img-previous
      options: root=UUID=4574dd5b-40ad-462f-bfbe-22676dd09bdc ro quiet loglevel=0 systemd.show_status=false splash

        title: Pop!_OS recovery
           id: Recovery-9D1B-C521.conf
       source: /boot/efi/loader/entries/Recovery-9D1B-C521.conf
        linux: /EFI/Recovery-9D1B-C521/vmlinuz.efi
       initrd: /EFI/Recovery-9D1B-C521/initrd.gz
      options: boot=casper hostname=recovery userfullname=Recovery username=recovery live-media-path=/casper-9D1B-C521 live-media=>

        title: Reboot Into Firmware Interface
           id: auto-reboot-to-firmware-setup
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f

As you can see, the default kernel to boot is set to the old-kernel option; but not explicit kernel version is specified and I can't figure out what version are the old and current kernels. But based on the behavior I see, I can guess probably that old = 5.16 and current = 5.17.

How can I fix this? I want to set the default boot kernel to be v5.15 and not change anymore.

1
  • While kernelstub -p doesn't reflect the changes (even after rebooting), uname -a does indeed show the updated/wanted version correctly.
    – mhogag
    Jan 13 at 17:03

2 Answers 2

2

First, your system has now been updated to kernel 5.17.5, and 5.16.19 is now probably the old-kernel. Please show the output of sudo bootctl list.

I don't use Pop OS myself, but as far as I've understood systemd-boot, the command to set the default boot entry is probably bootctl set-default, and the command to view the available boot entries is bootctl list.

Assuming I've understood correctly, kernelstub command just manages the details of each kernel, defaulting to operating on the newest one if you don't specify the exact kernel.

Since your kernelstub -v -l ... command apparently worked, there should be now a third entry for Pop OS in the bootctl list, with the 5.15 kernel that was first pushed into the old-kernel slot by 5.16 and then off the list entirely(?) by the introduction of 5.17. So you're on the right track, but just need a few more steps.

By using sudo bootctl list and sudo bootctl set-default you should be able to get the 5.15 kernel back into position as the default boot option.


After that, as long as you need to stick with your old ElasticSearch, you'll want to stop the new kernel packages from arriving. You should set up a package manager hold for the the kernel metapackage that has the latest kernel package as a dependency. It's the upgrade of the metapackage that triggers the installation of a new kernel image package.

In Debian, that would be linux-image-amd64, and the highest-level linux-image-generic would be a virtual package. It seems the Pop OS builders have simplified the structure a bit, and in your case, the metapackage would seem to be linux-image-generic instead.

You can use a GUI package manager to set up holds too, but on the command line it would be:

sudo apt-mark hold linux-image-generic

or

echo "linux-image-generic hold" | sudo dpkg --set-selections 

To view existing package holds:

dpkg --get-selections | grep "\<hold$"

or

apt-mark showhold

Eventually, you might upgrade your ElasticSearch or otherwise get rid of the requirement to keep with the 5.15 kernel. At that point, you would want to remove the hold to allow kernel updates again:

sudo apt-mark unhold linux-image-generic

or

echo "linux-image-generic install" | sudo dpkg --set-selections
1
  • Thanks for the reply. I updated my question with the output of bootctl list. As you can see there are only 2 options, and I think none of them is the 5.15 kernel. How can I add the 5.15 to the list of entries for bootctl? Jun 27, 2022 at 7:52
0

It is possible that your kernelstub command is working correctly, but you are still booting into the wrong kernel. I had a similar issue recently and noticed two things:

  1. The output from kernelstub -p does not change to show a different kernel, even if booting into the different kernel is correctly configured.
  2. Kernelstub will only change the 'current' boot option.

Therefore, it is possible that the command is working, however, when you reboot, the default option being 'old-kernel' means that you are not using the kernel you set up. If you run the command you have in your question, then reboot and select the 'current' option you should boot using the kernel you selected. You can confirm this by running uname -r to check the current kernel version in use.

2
  • Thanks for the answer, but this is not the case. After trying to change the boot kernel with ‍‍kernelstub, I checked both current and old and none of them were the kernel that I selected. Sep 18, 2022 at 7:09
  • The other thing you could try is to run the command with both the verbose and the dry-run flags. This should show you which kernel files are being copied to create the targets used by the bootloader.
    – FluxZA
    Sep 19, 2022 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .