Setting a specific Ubuntu kernel version

New Ubuntu kernels get installed as part of normal update and upgrade procedures. When running sudo apt update sometime the kernel version can be updated as well. The system will always boot the newest kernel by default, and any kernel change require re-installation of the driver (since it’s installed per kernel version).

Since driver modules are installed per kernel version, after such an update when trying to use the hailo pci_driver an error will be thrown.

In this guide we will show how to avoid automatic kernel changes and the need to re-install the pci driver , do the following steps:

0. Update your Ubuntu packages

sudo apt-get update

1. Install the wanted kernel

  1. Find all installed kernel versions

    dpkg --list | grep linux-image

  2. If the relevant kernel version is not installed, Install it:

    sudo apt-get install linux-image-VERSION-generic
    sudo apt-get install linux-modules-extra-VERSION-generic
    sudo apt-get install linux-headers-VERSION-generic
    

    For example, VERSION can be 5.15.0-78

2. Set the desired kernel as standard

  • Open the grub file

    vim /etc/default/grub

  • Update the GRUB_DEFAULT variable

    GRUB_DEFAULT='Advanced options for Ubuntu>Ubuntu, with Linux VERSION-generic'

  • If needed, change the following grub variables:

    # then wait for the timeout set by ‘GRUB_TIMEOUT’ to expire before booting the default entry.
    # If ‘GRUB_TIMEOUT_STYLE’ is set to ‘countdown’ or ‘hidden’, the timeout is instead 
    # counted before the menu is displayed.
    GRUB_TIMEOUT_STYLE=hidden 
    GRUB_TIMEOUT_STYLE=countdown
    
    # This will boot the default OS immediately. However, you may set it to 3 or 5 so you 
    # can press ESC (F4 or hold Shift) during the time to show the boot menu if needed.
    GRUB_TIMEOUT = 0 
    
    # Disable “/etc/grub.d/30_os-prober” because it overwrites the value of GRUB_TIMEOUT_STYLE. 
    # However, it will no longer find other OSs other than Ubuntu's.
    GRUB_DISABLE_OS_PROBER=true
    
    # Set timeout if last boot failed. Without the key, it will show and stop at boot menu 
    # waiting user action.
    GRUB_RECORDFAIL_TIMEOUT=0
    
    

3. Implement and save the changes

sudo update-grub

4. Reboot the machine

sudo reboot

5. Check the new installed kernel version

uname -r