Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vheidari/87d7353208f50463b2dad5946549520f to your computer and use it in GitHub Desktop.
Save vheidari/87d7353208f50463b2dad5946549520f to your computer and use it in GitHub Desktop.
Linux Mint - Rollbacking and switching between linux kernels with an example :)

Let's starting with a conflict, between Virtualbox and Qemu with kernel version

To compiling and running SerenityOS on linux Mint with kernel version "5.4.0-122-generic", qemu x86 has some isssus with this version of kernel. This version is too old for lastest version of qemu. to resolve this problems we just need to update linux kernel to newest version :

qemu error, when we runnig SerenityOs on 5.4.0-122-generic linux kernel :

qemu-system-i386: -gdb tcp:127.0.0.1:1234: gdbstub: KVM doesn't support guest debugging

To check current version on your Machine you can use following command inside your terminal:

uname -r

To resolve above error, Installing latest kernel version on Mint could help us for this reason just following below path in your Update Manager :

Update Mananger > view > Linux Kernel > select last version > install

After install it ( for this case we install this version "linux-headers-5.15.0-41-generic" ). Then we can run SerenityOS on qemu without any problems with latest kernel version but when we installing new kernel Virtualbox has problem to run virtual machines. because new kernel version is to new for VirtualBox. we use this Virtualbox version (Version 6.1.34).

To resolve this issue should we rollback linux kernel from ("5.15.0-41-generic") to ("5.4.0-122-generic") version. to run it again. for this case :

First we checking list of kernels that we installing before, with following command :

dpkg -l linux-header*

Above command show list of current linux kernel that installed on your machine. alternative path using with Update Manager

Update Mananger > view > Linux Kernel

After we made sure, we have installed these two kernel on our machine. my meaning is ("5.4.0-122-generic") and ("5.15.0-41-generic") we can start rollbacking.

To Change and rollbacking from ("5.15.0-41-generic") to ("5.4.0-122-generic") version Update Mananger doesn't help us.

Update Mananger > view > Linux Kernel

Above path just diplay active kernels and allow us to installing and removeing a kernel. but dont allow deactive ("5.15.0-41-generic") and then active this version ("5.4.0-122-generic")

For this reason we need change linux kernel from boot. to change and rolled back it following these below steps :

1. reboot your system with > reboot command inside terminal
2. before system booting press "Shift" key on your keyboard to system display Grub menu.
3. in Grub menu select "Advance options for ubuntu"
4. then select this ("5.4.0-122-generic") kernel version. then system does load and active this ("5.4.0-122-generic") version.

after that system done its jobs and booted.

you can check your curren active kernel with below command

uname -r

Then you could open your virtualbox and test it. you can see rollbacking linux kernel, could resolve problems and our system worked like a charm but if we try to run qemu we get some error. that in first part of this article we explained it.

Note : Switching between kernels in grub menu (Advance options for ubuntu) doesn't set choosed kernel as default kernel. for this reason if you want premanenltly rollbacking your kernel you should edit /etc/default/grub file and change GRUB_DEFAULT=0 to GRUB_DEFAULT=[proper_kernel_id]

to find proper_kernel_id you can check list of kernel that currently installed on your system with following command :

grep "menuentry" /boot/grub/grub.cfg

Above command show list of kernels that currently set in your grub.cfg file. which your grub can load thems. to find proper id for GRUB_DEFAULT= we should inspecting result of above command, to find right kernel id. for this case let's look at result for my machine :


if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
*[main_menu][1]* menuentry 'Linux Mint 20.3 MATE' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-96329e46-a6ex-96bb-h12d-1f3602512e96' { *[main_menu][1]*
submenu 'Advanced options for Linux Mint 20.3 MATE' $menuentry_id_option 'gnulinux-advanced-96329e46-a6ex-96bb-h12d-1f3602512e96' {
	*[sub_menu][0]* menuentry 'Linux Mint 20.3 MATE, with Linux 5.15.0-41-generic' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-41-generic-advanced-96329e46-a6ex-96bb-h12d-1f3602512e96' {
	*[sub_menu][1]* menuentry 'Linux Mint 20.3 MATE, with Linux 5.15.0-41-generic (recovery mode)' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.15.0-41-generic-recovery-96329e46-a6ex-96bb-h12d-1f3602512e96' {
	*[sub_menu][2]* menuentry 'Linux Mint 20.3 MATE, with Linux 5.4.0-122-generic' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-122-generic-advanced-96329e46-a6ex-96bb-h12d-1f3602512e96' {
	*[sub_menu][3]* menuentry 'Linux Mint 20.3 MATE, with Linux 5.4.0-122-generic (recovery mode)' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-122-generic-recovery-96329e46-a6ex-96bb-h12d-1f3602512e96' {
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {



In top result we marked grub main menu entry with *[main_menu][1]* and grub submenu entry for "Advanced options for Linux Mint 20.3 MATE" with *[sub_menu][0]* to *[sub_menu][n-1]*. to choosing right kernel it just enough to counting kernels that listed in result with numerical number from 0 to n-1.

in our example we want switching from Linux Mint 20.3 MATE, with Linux 5.15.0-41-generic to Linux Mint 20.3 MATE, with Linux 5.4.0-122-generic as you can see sub_menu id for Linux Mint 20.3 MATE, with Linux 5.4.0-122-generic == 2 which we indecated it with *[sub_menu][2]*

After we found *[main_menu][1]* and right *[sub_menu][2]* we should now go back and update GRUB_DEFAULT=[proper_kernel_id] with GRUB_DEFAULT="1>2" inside grub file in this path /etc/default/grub.

But what is 1>2 ?

- 1 is id for main_menu entry in grub menu 
- 2 is right kernel that we need to grub load it

After that when we update /etc/default/grub we need save it and update grub.cfg inside /boot/grub/grub.cfg with below command :

sudo update-grub

Congratulation we did it :). enjoy it.


Usefull reference :

- https://support.huaweicloud.com/intl/en-us/trouble-ecs/ecs_trouble_0327.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment