How to upgrade Linux kernel on Ubuntu

Method 1: Use System Update Process (Automatic Procedure)

  1. Update System Packages

    1
    $ sudo apt update

    This command retrieves information about the latest available package versions from the repositories configured on the system.

  2. Run the upgrade

    Run the following command to upgrade the installed packages, including the kernel, to the latest versions available in the repositories:

    1
    $ sudo apt upgrade

Method 2: Manually Update the Kernel (Advanced Procedure)

There’s another procedure for selecting and installing a new kernel using Mainline. This will take some risk from the untested kernel in mainline.

  1. Add the PPA maintained by cappelikan to the list of software sources or repositories

    1
    $ sudo add-apt-repository ppa:cappelikan/ppa
  2. Refresh the database

    1
    $ sudo apt update
  3. Install Mainline utility

    1
    $ sudo apt install mainline
  4. Launch Mainline utility

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    $sudo mainline
    mainline 1.4.9

    Mainline Kernels 1.4.9 - install kernel packages from https://kernel.ubuntu.com/mainline/

    Syntax: mainline <command> [options]

    Commands

    check Check for kernel updates
    notify Check for kernel updates and send a desktop notification
    list List the available kernels
    list-installed List the installed kernels
    install-latest Install the latest mainline kernel
    install-minor Install the latest mainline kernel without going to a new major version
    install <names> Install the specified kernels(1)(2)
    uninstall <names> Uninstall the specified kernels(1)(2)
    uninstall-old Uninstall all but the highest installed version(2)
    download <names> Download the specified kernels(1)
    lock <names> Lock the specified kernels(1)
    unlock <names> Unlock the specified kernels(1)
    delete-cache Delete the cached info about available kernels
    write-config Write the given include/exclude & previous-majors options to the config file
    help This help

    Options

    --include-rc Include release-candidate and unstable releases
    --exclude-rc Exclude release-candidate and unstable releases
    --include-flavors Include flavors other than "generic"
    --exclude-flavors Exclude flavors other than "generic"
    --include-invalid Include failed/incomplete builds
    --exclude-invalid Exclude failed/incomplete builds
    --previous-majors # Include # (or "all" or "none") previous major versions
    --include-all Short for "--include-rc --include-flavors --include-invalid --previous-majors all"
    --exclude-all Short for "--exclude-rc --exclude-flavors --exclude-invalid --previous-majors none"
    -n|--dry-run Don't actually install or uninstall
    -v|--verbose [#] Set verbosity level to #, or increment by 1
    --pause Pause and require keypress before exiting

    Notes
    (1) One or more version strings taken from the output of "list"
    comma, pipe, colon, or space separated. (space requires quotes or backslashes)
    (2) Locked kernels and the currently running kernel are ignored

    mainline: done
  5. List the installed kernel versions

    1
    2
    3
    4
    5
    6
    7
    8
    $ sudo mainline list-installed
    mainline 1.4.9
    Installed Kernels:
    linux-image-5.15.0-94-generic
    linux-image-6.5.0-17-generic
    linux-image-generic
    linux-image-generic-hwe-22.04
    mainline: done
  6. List the available kernel versions

    1
    $ sudo mainline list
  7. Install the kernel

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $ sudo mainline install 6.3

    $ sudo mainline list-installed
    mainline 1.4.9
    Installed Kernels:
    linux-image-5.15.0-94-generic
    linux-image-6.5.0-17-generic
    linux-image-generic
    linux-image-generic-hwe-22.04
    linux-image-unsigned-5.7.12-050712-generic
    linux-image-unsigned-6.3.0-060300-generic
    mainline: done
  8. Boot system with newly installed kernel

    Reboot the system and hold the Shift key or Esc key, depending on the Linux distribution.

    Select Advanced options for Ubuntu and choose the kernel to boot up.