How to upgrade kernel to latest version on Ubuntu 21.04

First download the bash script utility from the github by using "wget" command.

wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh

Output:

root@vps:~# wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
--2021-05-01 13:54:46--  https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 26474 (26K) [text/plain]
Saving to: ‘ubuntu-mainline-kernel.sh’

ubuntu-mainline-ker 100%[===================>]  25.85K  --.-KB/s    in 0.001s

2021-05-01 13:54:47 (45.3 MB/s) - ‘ubuntu-mainline-kernel.sh’ saved [26474/26474]

Install the previously downloaded script into our executable path with following command.

install ubuntu-mainline-kernel.sh /usr/local/bin/

Next, Run the downloaded script to upgrade the Ubuntu kernel to the latest version. During the time of installation it'll ask you permission to install latest kernel version press "Y" to continue.

ubuntu-mainline-kernel.sh -i

Output:

root@vps:~# ubuntu-mainline-kernel.sh -i
Finding latest version available on kernel.ubuntu.com
Latest version is: v5.12.0, continue? (y/N)
Will download 6 files from kernel.ubuntu.com:
Downloading amd64/linux-headers-5.12.0-051200-generic_5.12.0-051200.202104252130_amd64.deb: 100%
Downloading amd64/linux-headers-5.12.0-051200_5.12.0-051200.202104252130_all.deb: 100%
Downloading amd64/linux-image-unsigned-5.12.0-051200-generic_5.12.0-051200.202104252130_amd64.deb: 100%
Downloading amd64/linux-modules-5.12.0-051200-generic_5.12.0-051200.202104252130_amd64.deb: 100%
Downloading amd64/CHECKSUMS: 100%
Downloading amd64/CHECKSUMS.gpg: 100%
Importing kernel-ppa gpg key ok
Signature of checksum file has been successfully verified
Checksums of deb files have been successfully verified with sha256sum
Installing 4 packages
Cleaning up work folder

Once upgrade command is over reboot your Ubuntu system and check for the loaded Kernel version.

uname -rs

Output:

root@vps:~# uname -rs
Linux 5.12.0-051200-generic

Done!