Hello, @Khushi Gupta !
How do I downgrade or roll back the kernel version of Ubuntu on an Azure VM?
Adding to what @Andriy Bilous has said, the instructions from danielstechblog.io have worked for other people in an answer from @Andriy Bilous on another thread:
You may try to downgrade kernel. Here is an example for Ubuntu 20.04
Identify actual kernel with command:
sudo uname -a
Linux test 5.11.0-1021-azure #22~20.04.1-Ubuntu SMP Fri Oct 29 01:11:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
First step is to identify the necessary packages that you need to install. This is done by executing the following command.
sudo apt search linux-azure | grep 5.4.0-1062
Afterwards you know which package needs to be installed.
sudo apt install linux-image-5.4.0-1062-azure
In the next step the actual kernel gets removed.
sudo apt remove linux-image-5.11.0-1021-azure
During the process you confirm with <No> that you do not want to abort the removal process.
Kernel removal confirmation window
As the last step you initiate a reboot with sudo reboot
The welcome screen should now state the target kernel version.
Check the kernel version
sudo uname -a
Linux test 5.4.0-1062-azure #65-Ubuntu SMP Sun Oct 10 02:30:34 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
https://www.danielstechblog.io/downgrade-the-linux-kernel-on-an-azure-ubuntu-vm/
Other options
If you are rolling back the kernel to address VM issues after applying kernel changes, the recommendation is to delete the affected Linux VM and keep the operating system disk which is then attached to a new VM with the same version and running one of the following repair options:
https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/kernel-related-boot-issues
- Roll back the kernel and start from a previous working setup by editing the configuration file.
- Install or reinstall a kernel by attaching the affected VM operating system disk to a temporary new VM and running a tool like apt-get, Yellowdog Updater Modified (YUM), or Zypper. See Linux Recovery: Using CHROOT steps to recover VMs that are not accessible.