Tag Archives: downgrade kernel in Suse linux

Boot SUSE Linux from old kernel after kernel upgrade

How to guide to boot Suse Linux from old kernel after kernel upgrade. 

Boot Suse Linux from old kernel after kernel upgrade

This article is basically a how-to guide for booting SUSE Linux system from the previous kernel after the kernel upgrade process. Normally, Linux like Red Hat has the option to just change boot priority of kernel in /etc/grub.conf and reboot into the kernel of your choice. But in SUSE Linux, we do not have that option. Now the question is how to boot into old kernel once I upgrade the kernel.

You can boot into the older kernel by using the below method. I explained kernel upgrade first and then how to uninstall update to boot from the older kernel. This is a kind of rollback kernel upgrade in SUSE Linux.

1. Upgrade kernel in Suse Linux

The first thing you want to check and confirm that if your SUSE supports multiversion or not.  Go to /etc/zypp/zypp.conf and make sure the below-mentioned line is not commented on. If there is # at the beginning of it, remove it.

multiversion = provides:multiversion(kernel)

There are many ways to maintain how many old kernel versions can be maintained by the system. We won’t be going through it. You can find more details about it here.

Once you are confirmed, multiversion is active then go ahead with kernel upgrade. If it’s not activated, zypper will auto-delete old kernel and you won’t be able to use it.

Check current kernel version

root@kerneltalks # uname -a
Linux kerneltalks 4.4.114-94.11-default #1 SMP Thu Feb 1 19:28:26 UTC 2018 (4309ff9) x86_64 x86_64 x86_64 GNU/Linux

Install the new kernel version using zypper.  Make sure you are installing the new kernel and not updating your current one.

root@kerneltalks # zypper in kernel-default
Refreshing service 'SMT-http_smt-ec2_susecloud_net'.
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 5 NEW packages are going to be installed:
  crash-kmp-default crda kernel-default-4.4.120-94.17.1 kernel-firmware
  wireless-regdb

5 new packages to install.
Overall download size: 81.3 MiB. Already cached: 0 B. After the operation,
additional 358.3 MiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package kernel-default-4.4.120-94.17.1.x86_64
                                           (1/5),  38.6 MiB (167.2 MiB unpacked)
Retrieving: kernel-default-4.4.120-94.17.1.x86_64.rpm ........[done (7.1 MiB/s)]
Retrieving package kernel-firmware-20170530-21.19.1.noarch
                                           (2/5),  42.5 MiB (191.1 MiB unpacked)
Retrieving: kernel-firmware-20170530-21.19.1.noarch.rpm .....[done (18.2 MiB/s)]
Retrieving package wireless-regdb-2017.12.23-4.3.1.noarch
                                           (3/5),  14.1 KiB ( 13.0 KiB unpacked)
Retrieving: wireless-regdb-2017.12.23-4.3.1.noarch.rpm ...................[done]
Retrieving package crash-kmp-default-7.1.8_k4.4.92_6.30-4.6.2.x86_64
                                           (4/5), 116.8 KiB (  7.8 KiB unpacked)
Retrieving: crash-kmp-default-7.1.8_k4.4.92_6.30-4.6.2.x86_64.rpm ........[done]
Retrieving package crda-1.1.3-4.2.1.x86_64 (5/5),  14.4 KiB ( 34.5 KiB unpacked)
Retrieving: crda-1.1.3-4.2.1.x86_64.rpm ..................................[done]
Checking for file conflicts: .............................................[done]
(1/5) Installing: kernel-default-4.4.120-94.17.1.x86_64 ..................[done]
Additional rpm output:
Creating initrd: /boot/initrd-4.4.120-94.17-default
dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force                                                                                         /boot/initrd-4.4.120-94.17-default 4.4.120-94.17-default
dracut: dracut module 'btrfs' will not be installed, because command 'btrfs' cou                                                                                        ld not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' c                                                                                        ould not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' co                                                                                        uld not be found!
dracut: dracut module 'btrfs' will not be installed, because command 'btrfs' cou                                                                                        ld not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' c                                                                                        ould not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' co                                                                                        uld not be found!
dracut: *** Including module: bash ***
dracut: *** Including module: systemd ***
dracut: *** Including module: systemd-initrd ***
dracut: *** Including module: i18n ***
dracut: No KEYMAP configured.
dracut: *** Including module: xen-tools-domU ***
dracut: *** Including module: kernel-modules ***
dracut: *** Including module: rootfs-block ***
dracut: *** Including module: suse-xfs ***
dracut: *** Including module: terminfo ***
dracut: *** Including module: udev-rules ***
dracut: Skipping udev rule: 40-redhat.rules
dracut: Skipping udev rule: 50-firmware.rules
dracut: Skipping udev rule: 50-udev.rules
dracut: Skipping udev rule: 91-permissions.rules
dracut: Skipping udev rule: 80-drivers-modprobe.rules
dracut: *** Including module: dracut-systemd ***
dracut: *** Including module: haveged ***
dracut: *** Including module: usrmount ***
dracut: *** Including module: base ***
dracut: *** Including module: fs-lib ***
dracut: *** Including module: shutdown ***
dracut: *** Including module: suse ***
dracut: *** Including modules done ***
dracut: *** Installing kernel module dependencies and firmware ***
dracut: *** Installing kernel module dependencies and firmware done ***
dracut: *** Resolving executable dependencies ***
dracut: *** Resolving executable dependencies done***
dracut: *** Hardlinking files ***
dracut: *** Hardlinking files done ***
dracut: *** Stripping files ***
dracut: *** Stripping files done ***
dracut: *** Generating early-microcode cpio image ***
dracut: *** Store current command line parameters ***
dracut: Stored kernel commandline:
dracut:  root=UUID=26fa33a2-ad40-4a85-a495-402aca6a2127 rootfstype=ext4 rootflag                                                                                        s=rw,relatime,data=ordered
dracut: *** Creating image file '/boot/initrd-4.4.120-94.17-default' ***
dracut: *** Creating initramfs image file '/boot/initrd-4.4.120-94.17-default' d                                                                                        one ***


(2/5) Installing: kernel-firmware-20170530-21.19.1.noarch ................[done]
(3/5) Installing: wireless-regdb-2017.12.23-4.3.1.noarch .................[done]
(4/5) Installing: crash-kmp-default-7.1.8_k4.4.92_6.30-4.6.2.x86_64 ......[done]
(5/5) Installing: crda-1.1.3-4.2.1.x86_64 ................................[done]
Output of kernel-firmware-20170530-21.19.1.noarch.rpm %posttrans script:
    Creating initrd: /boot/initrd-4.4.114-94.11-default
    dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --f                                                                                        orce /boot/initrd-4.4.114-94.11-default 4.4.114-94.11-default
    dracut: dracut module 'btrfs' will not be installed, because command 'btrfs'                                                                                         could not be found!
    dracut: dracut module 'dmraid' will not be installed, because command 'dmrai                                                                                        d' could not be found!
    dracut: dracut module 'mdraid' will not be installed, because command 'mdadm                                                                                        ' could not be found!
    dracut: dracut module 'btrfs' will not be installed, because command 'btrfs'                                                                                         could not be found!
    dracut: dracut module 'dmraid' will not be installed, because command 'dmrai                                                                                        d' could not be found!
    dracut: dracut module 'mdraid' will not be installed, because command 'mdadm                                                                                        ' could not be found!
    dracut: *** Including module: bash ***
    dracut: *** Including module: systemd ***
    dracut: *** Including module: systemd-initrd ***
    dracut: *** Including module: i18n ***
    dracut: No KEYMAP configured.
    dracut: *** Including module: xen-tools-domU ***
    dracut: *** Including module: kernel-modules ***
    dracut: *** Including module: rootfs-block ***
    dracut: *** Including module: suse-xfs ***
    dracut: *** Including module: terminfo ***
    dracut: *** Including module: udev-rules ***
    dracut: Skipping udev rule: 40-redhat.rules
    dracut: Skipping udev rule: 50-firmware.rules
    dracut: Skipping udev rule: 50-udev.rules
    dracut: Skipping udev rule: 91-permissions.rules
    dracut: Skipping udev rule: 80-drivers-modprobe.rules
    dracut: *** Including module: dracut-systemd ***
    dracut: *** Including module: haveged ***
    dracut: *** Including module: usrmount ***
    dracut: *** Including module: base ***
    dracut: *** Including module: fs-lib ***
    dracut: *** Including module: shutdown ***
    dracut: *** Including module: suse ***
    dracut: *** Including modules done ***
    dracut: *** Installing kernel module dependencies and firmware ***
    dracut: *** Installing kernel module dependencies and firmware done ***
    dracut: *** Resolving executable dependencies ***
    dracut: *** Resolving executable dependencies done***
    dracut: *** Hardlinking files ***
    dracut: *** Hardlinking files done ***
    dracut: *** Stripping files ***
    dracut: *** Stripping files done ***
    dracut: *** Generating early-microcode cpio image ***
    dracut: *** Store current command line parameters ***
    dracut: Stored kernel commandline:
    dracut:  root=UUID=26fa33a2-ad40-4a85-a495-402aca6a2127 rootfstype=ext4 root                                                                                        flags=rw,relatime,data=ordered
    dracut: *** Creating image file '/boot/initrd-4.4.114-94.11-default' ***
    dracut: *** Creating initramfs image file '/boot/initrd-4.4.114-94.11-defaul                                                                                        t' done ***
    Creating initrd: /boot/initrd-4.4.120-94.17-default
    dracut: Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --f                                                                                        orce /boot/initrd-4.4.120-94.17-default 4.4.120-94.17-default
    dracut: dracut module 'btrfs' will not be installed, because command 'btrfs'                                                                                         could not be found!
    dracut: dracut module 'dmraid' will not be installed, because command 'dmrai                                                                                        d' could not be found!
    dracut: dracut module 'mdraid' will not be installed, because command 'mdadm                                                                                        ' could not be found!
    dracut: dracut module 'btrfs' will not be installed, because command 'btrfs'                                                                                         could not be found!
    dracut: dracut module 'dmraid' will not be installed, because command 'dmrai                                                                                        d' could not be found!
    dracut: dracut module 'mdraid' will not be installed, because command 'mdadm                                                                                        ' could not be found!
    dracut: *** Including module: bash ***
    dracut: *** Including module: systemd ***
    dracut: *** Including module: systemd-initrd ***
    dracut: *** Including module: i18n ***
    dracut: No KEYMAP configured.
    dracut: *** Including module: xen-tools-domU ***
    dracut: *** Including module: kernel-modules ***
    dracut: *** Including module: rootfs-block ***
    dracut: *** Including module: suse-xfs ***
    dracut: *** Including module: terminfo ***
    dracut: *** Including module: udev-rules ***
    dracut: Skipping udev rule: 40-redhat.rules
    dracut: Skipping udev rule: 50-firmware.rules
    dracut: Skipping udev rule: 50-udev.rules
    dracut: Skipping udev rule: 91-permissions.rules
    dracut: Skipping udev rule: 80-drivers-modprobe.rules
    dracut: *** Including module: dracut-systemd ***
    dracut: *** Including module: haveged ***
    dracut: *** Including module: usrmount ***
    dracut: *** Including module: base ***
    dracut: *** Including module: fs-lib ***
    dracut: *** Including module: shutdown ***
    dracut: *** Including module: suse ***
    dracut: *** Including modules done ***
    dracut: *** Installing kernel module dependencies and firmware ***
    dracut: *** Installing kernel module dependencies and firmware done ***
    dracut: *** Resolving executable dependencies ***
    dracut: *** Resolving executable dependencies done***
    dracut: *** Hardlinking files ***
    dracut: *** Hardlinking files done ***
    dracut: *** Stripping files ***
    dracut: *** Stripping files done ***
    dracut: *** Generating early-microcode cpio image ***
    dracut: *** Store current command line parameters ***
    dracut: Stored kernel commandline:
    dracut:  root=UUID=26fa33a2-ad40-4a85-a495-402aca6a2127 rootfstype=ext4 root                                                                                        flags=rw,relatime,data=ordered
    dracut: *** Creating image file '/boot/initrd-4.4.120-94.17-default' ***
    dracut: *** Creating initramfs image file '/boot/initrd-4.4.120-94.17-defaul                                                                                        t' done ***

Reboot system and you see your system is booted with the latest new kernel.

root@kerneltalks # uname -a
Linux kerneltalks 4.4.120-94.17-default #1 SMP Wed Mar 14 17:23:00 UTC 2018                                                                                         (cf3a7bb) x86_64 x86_64 x86_64 GNU/Linux

Now check all the installed kernel packages on your system using –

root@kerneltalks # zypper se -si 'kernel*'
Refreshing service 'SMT-http_smt-ec2_susecloud_net'.
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...

S  | Name            | Type    | Version          | Arch   | Repository
---+-----------------+---------+------------------+--------+-------------------
i+ | kernel-default  | package | 4.4.120-94.17.1  | x86_64 | SLES12-SP3-Updates
i+ | kernel-default  | package | 4.4.114-94.11.3  | x86_64 | SLES12-SP3-Updates
i  | kernel-firmware | package | 20170530-21.19.1 | noarch | SLES12-SP3-Updates

Here, you can see there are two kernels installed on the system. Old one is 4.4.114-94.11.3 and the new one is 4.4.120-94.17.1 from which the current system is booted.

2. Boot from the old kernel in SUSE Linux

For Suse with GRUB2

Now, if you want to boot the system from the old kernel 4.4.114-94.11.3 without un-installing new kernel then follow the below steps.

Make copy of /etc/default/grub file as a backup. and then edit it –

root@kerneltalks # cp /etc/default/grub /etc/default/grub.backup
root@kerneltalks # vi /etc/default/grub

Look for GRUB_DEFAULT=0and edit the number per old kernel menu number. Old kernel menu number can be found in /boot/grub2/grub.cfg

Open /boot/grub2/grub.cfg and look for entry menuentry You will be able to see different kernel entries in it. First being 0 and then counter goes on. Check and choose the menu number of your old kernel.

After editing /etc/default/grub file you need to re-create /boot/grub2/grub.cfg You can do it with below command –

root@kerneltalks # grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.120-94.17-default
Found initrd image: /boot/initrd-4.4.120-94.17-default
Found linux image: /boot/vmlinuz-4.4.114-94.11-default
Found initrd image: /boot/initrd-4.4.114-94.11-default
done

Once done, reboot the system. That’s it. You can see your system is booted with an old kernel while your new kernel is still installed on the server.

For Suse with GRUB

Edit /boot/grub/grub.conf which is also link to /boot/grub/menu.lst . Look for parameter default 0 and change the number 0 to your desired kernel menu number.

You can see the kernel list to be displayed later in the same file. Remember, the numbering starts at 0. So countdown to your old kernel version number and use it for the default parameter.

Save the file and reboot the system. You will be booted with old kernel.

3. Rollback to old kernel in SUSE Linux

Now if you want to rollback system to the old kernel 4.4.114-94.11.3, remove this latest installed kernel 4.4.120-94.17.1. You need to give kernel name as <package_name>-<package_version>. You can get the version from the above command output. In this way, we are downgrading kernel in SUSE Linux.

root@kerneltalks # zypper rm kernel-default-4.4.120-94.17.1
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following package is going to be REMOVED:
  kernel-default-4.4.120-94.17.1

1 package to remove.
After the operation, 167.2 MiB will be freed.
Continue? [y/n/...? shows all options] (y): y
(1/1) Removing kernel-default-4.4.120-94.17.1.x86_64 .............................................................................................................[done]
There are some running programs that might use files deleted by recent upgrade. You may wish to check and restart some of them. Run 'zypper ps -s' to list these programs.

Now as per warning lets check which all processes are using it.

root@kerneltalks # zypper ps -s
The following running processes use deleted files:

PID | PPID | UID | User | Command       | Service
----+------+-----+------+---------------+--------------
486 | 1    | 0   | root | systemd-udevd | systemd-udevd

You may wish to restart these processes.
See 'man zypper' for information about the meaning of values in the above table.

Lets reboot system and check kernel version.

root@kerneltalks # uname -a
Linux kerneltalks 4.4.114-94.11-default #1 SMP Thu Feb 1 19:28:26 UTC 2018 (4309ff9) x86_64 x86_64 x86_64 GNU/Linux

You can see the system is booted with your old kernel 4.4.114-94.11.3!

Now, Check installed kernel packages and you can see a newer kernel package is no more installed/active on the system.

root@kerneltalks # zypper se -si 'kernel*'
Refreshing service 'SMT-http_smt-ec2_susecloud_net'.
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...

S  | Name            | Type    | Version          | Arch   | Repository
---+-----------------+---------+------------------+--------+-------------------
i+ | kernel-default  | package | 4.4.114-94.11.3  | x86_64 | SLES12-SP3-Updates
i  | kernel-firmware | package | 20170530-21.19.1 | noarch | SLES12-SP3-Updates

If you have another method (command line) to boot into the older kernel then please share in the comments below.