In the previous post, we saw how to update CentOS 8 / RHEL 8 system to have the latest updates on your system. Rarely, the updates may break your system or application that is running on top of it.
In this case, you may need to revert the updated packages to the previous version.
In this post, we will see the steps to revert OS patching on CentOS 8 / RHEL 8.
Update History
Contents
The yum history command will list all activities you did with yum command, including the OS patching.
yum history
From the above output, you can see
ID 4: OS patching (Command line: update) as it has (I)nstall and (U)pdate actions of 55 packages.
ID 3: Kernel update (Command line: update -y kernel) (I)nstall action of 3 packages
You can also find out what were the packages got updated during the history ID 4 or 3 with the below command.
I am checking the information of the history ID 3.
yum history info 3
Output:
Transaction ID : 3 Begin time : Wed 23 Oct 2019 04:50:02 AM EDT Begin rpmdb : 390:36e45bfafdb36c1b565f744db484c136e60d027c End time : Wed 23 Oct 2019 04:52:29 AM EDT (147 seconds) End rpmdb : 393:2dbf7c6498447e95a25b76af117b689bccd11b20 User : root Return-Code : Success Releasever : 8 Command Line : update -y kernel Packages Altered: Install kernel-4.18.0-80.11.2.el8_0.x86_64 @BaseOS Install kernel-core-4.18.0-80.11.2.el8_0.x86_64 @BaseOS Install kernel-modules-4.18.0-80.11.2.el8_0.x86_64 @BaseOS [root@centos8 ~]# yum history info 4 Transaction ID : 4 Begin time : Wed 23 Oct 2019 04:57:30 AM EDT Begin rpmdb : 393:2dbf7c6498447e95a25b76af117b689bccd11b20 End time : Wed 23 Oct 2019 05:02:37 AM EDT (5 minutes) End rpmdb : 394:2263176203aedb3134fb7478167919e2cb60450b User : root Return-Code : Success Releasever : 8 Command Line : update Packages Altered: Install grub2-tools-efi-1:2.02-66.el8_0.1.x86_64 @BaseOS Upgrade bash-4.4.19-8.el8_0.x86_64 @BaseOS Upgraded bash-4.4.19-7.el8.x86_64 @@System Upgrade bind-export-libs-32:9.11.4-17.P2.el8_0.1.x86_64 @BaseOS Upgraded bind-export-libs-32:9.11.4-16.P2.el8.x86_64 @@System Upgrade grub2-common-1:2.02-66.el8_0.1.noarch @BaseOS Upgraded grub2-common-1:2.02-66.el8.noarch @@System . . . . . . Upgrade sssd-nfs-idmap-2.0.0-43.el8_0.3.x86_64 @BaseOS Upgraded sssd-nfs-idmap-2.0.0-43.el8.x86_64 @@System Upgrade systemd-239-13.el8_0.5.x86_64 @BaseOS Upgraded systemd-239-13.el8.x86_64 @@System Upgrade systemd-libs-239-13.el8_0.5.x86_64 @BaseOS Upgraded systemd-libs-239-13.el8.x86_64 @@System Upgrade systemd-pam-239-13.el8_0.5.x86_64 @BaseOS Upgraded systemd-pam-239-13.el8.x86_64 @@System Upgrade systemd-udev-239-13.el8_0.5.x86_64 @BaseOS Upgraded systemd-udev-239-13.el8.x86_64 @@System Upgrade epel-release-8-6.el8.noarch @epel Upgraded epel-release-8-5.el8.noarch @@System Scriptlet output: 1 warning: /etc/shadow created as /etc/shadow.rpmnew
Likewise, you can see the information of other ID’s.
Revert Updates
Once you have identified the OS patching ID and Kernel update ID (Optional as most the time updated Kernel is installed along with OS patching), please go ahead to revert the update one by one.
Kernel
This step is not applicable if the Kernel was installed along with OS patching (yum update).
Use the yum history undo with 3 to revert the activities (remove kernel updates).
yum history undo 3
Output:
Last metadata expiration check: 1:24:58 ago on Wed 23 Oct 2019 05:19:07 AM EDT. Undoing transaction 3, from Wed 23 Oct 2019 04:50:02 AM EDT Install kernel-4.18.0-80.11.2.el8_0.x86_64 @BaseOS Install kernel-core-4.18.0-80.11.2.el8_0.x86_64 @BaseOS Install kernel-modules-4.18.0-80.11.2.el8_0.x86_64 @BaseOS Dependencies resolved. ============================================================================================================================ Package Arch Version Repository Size ============================================================================================================================ Removing: kernel x86_64 4.18.0-80.11.2.el8_0 @BaseOS 0 kernel-core x86_64 4.18.0-80.11.2.el8_0 @BaseOS 57 M kernel-modules x86_64 4.18.0-80.11.2.el8_0 @BaseOS 19 M Transaction Summary ============================================================================================================================ Remove 3 Packages Freed space: 76 M Is this ok [y/N]: Y << Press Y and Enter to revert Kernel Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Erasing : kernel-4.18.0-80.11.2.el8_0.x86_64 1/3 Running scriptlet: kernel-4.18.0-80.11.2.el8_0.x86_64 1/3 Erasing : kernel-modules-4.18.0-80.11.2.el8_0.x86_64 2/3 Running scriptlet: kernel-modules-4.18.0-80.11.2.el8_0.x86_64 2/3 Running scriptlet: kernel-core-4.18.0-80.11.2.el8_0.x86_64 3/3 Erasing : kernel-core-4.18.0-80.11.2.el8_0.x86_64 3/3 Running scriptlet: kernel-core-4.18.0-80.11.2.el8_0.x86_64 3/3 Verifying : kernel-4.18.0-80.11.2.el8_0.x86_64 1/3 Verifying : kernel-core-4.18.0-80.11.2.el8_0.x86_64 2/3 Verifying : kernel-modules-4.18.0-80.11.2.el8_0.x86_64 3/3 Removed: kernel-4.18.0-80.11.2.el8_0.x86_64 kernel-core-4.18.0-80.11.2.el8_0.x86_64 kernel-modules-4.18.0-80.11.2.el8_0.x86_64 Complete!
Packages
Use the yum history undo with 4 to revert the activities (revert OS updates).
yum history undo 4
Output:
Last metadata expiration check: 1:38:10 ago on Wed 23 Oct 2019 05:19:07 AM EDT. Undoing transaction 4, from Wed 23 Oct 2019 04:57:30 AM EDT Install grub2-tools-efi-1:2.02-66.el8_0.1.x86_64 @BaseOS Upgrade bash-4.4.19-8.el8_0.x86_64 @BaseOS Upgraded bash-4.4.19-7.el8.x86_64 @@System Upgrade bind-export-libs-32:9.11.4-17.P2.el8_0.1.x86_64 @BaseOS Upgraded bind-export-libs-32:9.11.4-16.P2.el8.x86_64 @@System Upgrade grub2-common-1:2.02-66.el8_0.1.noarch @BaseOS Upgraded grub2-common-1:2.02-66.el8.noarch @@System Upgrade grub2-pc-1:2.02-66.el8_0.1.x86_64 @BaseOS Upgraded grub2-pc-1:2.02-66.el8.x86_64 @@System Upgrade grub2-pc-modules-1:2.02-66.el8_0.1.noarch @BaseOS . . . . . . Upgrade epel-release-8-6.el8.noarch @epel Upgraded epel-release-8-5.el8.noarch @@System Dependencies resolved. ============================================================================================================================ Package Arch Version Repository Size ============================================================================================================================ Removing: grub2-tools-efi x86_64 1:2.02-66.el8_0.1 @BaseOS 1.9 M Downgrading: bash x86_64 4.4.19-7.el8 BaseOS 1.5 M bind-export-libs x86_64 32:9.11.4-16.P2.el8 BaseOS 1.1 M grub2-common noarch 1:2.02-66.el8 BaseOS 880 k grub2-pc x86_64 1:2.02-66.el8 BaseOS 35 k grub2-pc-modules noarch 1:2.02-66.el8 BaseOS 899 k . . . . . . systemd x86_64 239-13.el8 BaseOS 3.4 M systemd-libs x86_64 239-13.el8 BaseOS 550 k systemd-pam x86_64 239-13.el8 BaseOS 221 k systemd-udev x86_64 239-13.el8 BaseOS 1.3 M epel-release noarch 8-5.el8 extras 22 k Transaction Summary ============================================================================================================================ Remove 1 Package Downgrade 50 Packages Total download size: 46 M Is this ok [y/N]: Y << Press Y and Enter to Revert Updates Downloading Packages: (1/50): bash-4.4.19-7.el8.x86_64.rpm 966 kB/s | 1.5 MB 00:01 (2/50): grub2-common-2.02-66.el8.noarch.rpm 530 kB/s | 880 kB 00:01 (3/50): grub2-pc-2.02-66.el8.x86_64.rpm 537 kB/s | 35 kB 00:00 (4/50): bind-export-libs-9.11.4-16.P2.el8.x86_64.rpm 640 kB/s | 1.1 MB 00:01 (5/50): grub2-tools-2.02-66.el8.x86_64.rpm 3.7 MB/s | 1.9 MB 00:00 (6/50): grub2-pc-modules-2.02-66.el8.noarch.rpm 1.4 MB/s | 899 kB 00:00 (7/50): grub2-tools-minimal-2.02-66.el8.x86_64.rpm 2.0 MB/s | 196 kB 00:00 . . . . . . (46/50): systemd-pam-239-13.el8.x86_64.rpm 1.6 MB/s | 221 kB 00:00 (47/50): selinux-policy-targeted-3.14.1-61.el8.noarch.rpm 3.7 MB/s | 15 MB 00:04 (48/50): python3-libs-3.6.8-1.el8.0.1.x86_64.rpm 1.6 MB/s | 7.9 MB 00:04 (49/50): systemd-udev-239-13.el8.x86_64.rpm 1.7 MB/s | 1.3 MB 00:00 (50/50): epel-release-8-5.el8.noarch.rpm 77 kB/s | 22 kB 00:00 ---------------------------------------------------------------------------------------------------------------------------- Total 4.1 MB/s | 46 MB 00:11 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: bash-4.4.19-7.el8.x86_64 1/1 Downgrading : bash-4.4.19-7.el8.x86_64 1/101 Running scriptlet: bash-4.4.19-7.el8.x86_64 1/101 Downgrading : platform-python-3.6.8-1.el8.0.1.x86_64 2/101 Running scriptlet: platform-python-3.6.8-1.el8.0.1.x86_64 2/101 Downgrading : python3-libs-3.6.8-1.el8.0.1.x86_64 3/101 Downgrading : grub2-common-1:2.02-66.el8.noarch 4/101 . . . . . . Verifying : epel-release-8-5.el8.noarch 99/101 Verifying : epel-release-8-6.el8.noarch 100/101 Verifying : grub2-tools-efi-1:2.02-66.el8_0.1.x86_64 101/101 Downgraded: bash-4.4.19-7.el8.x86_64 bind-export-libs-32:9.11.4-16.P2.el8.x86_64 grub2-common-1:2.02-66.el8.noarch grub2-pc-1:2.02-66.el8.x86_64 grub2-pc-modules-1:2.02-66.el8.noarch grub2-tools-1:2.02-66.el8.x86_64 grub2-tools-extra-1:2.02-66.el8.x86_64 grub2-tools-minimal-1:2.02-66.el8.x86_64 initscripts-10.00.1-1.el8.x86_64 iptables-1.8.2-9.el8.x86_64 iptables-ebtables-1.8.2-9.el8.x86_64 iptables-libs-1.8.2-9.el8.x86_64 kernel-tools-4.18.0-80.el8.x86_64 kernel-tools-libs-4.18.0-80.el8.x86_64 kmod-25-11.el8.x86_64 kmod-libs-25-11.el8.x86_64 kpartx-0.7.8-7.el8.x86_64 libdnf-0.22.5-4.el8.x86_64 libnfsidmap-1:2.3.3-14.el8.x86_64 libsss_autofs-2.0.0-43.el8.x86_64 libsss_certmap-2.0.0-43.el8.x86_64 libsss_idmap-2.0.0-43.el8.x86_64 libsss_nss_idmap-2.0.0-43.el8.x86_64 libsss_sudo-2.0.0-43.el8.x86_64 microcode_ctl-4:20180807a-2.el8.x86_64 p11-kit-0.23.14-4.el8.x86_64 p11-kit-trust-0.23.14-4.el8.x86_64 platform-python-3.6.8-1.el8.0.1.x86_64 python3-hawkey-0.22.5-4.el8.x86_64 python3-libdnf-0.22.5-4.el8.x86_64 python3-libs-3.6.8-1.el8.0.1.x86_64 python3-perf-4.18.0-80.el8.x86_64 python3-rpm-4.14.2-9.el8.x86_64 rpm-4.14.2-9.el8.x86_64 rpm-build-libs-4.14.2-9.el8.x86_64 rpm-libs-4.14.2-9.el8.x86_64 rpm-plugin-selinux-4.14.2-9.el8.x86_64 rpm-plugin-systemd-inhibit-4.14.2-9.el8.x86_64 selinux-policy-3.14.1-61.el8.noarch selinux-policy-targeted-3.14.1-61.el8.noarch setup-2.12.2-1.el8.noarch sssd-client-2.0.0-43.el8.x86_64 sssd-common-2.0.0-43.el8.x86_64 sssd-kcm-2.0.0-43.el8.x86_64 sssd-nfs-idmap-2.0.0-43.el8.x86_64 systemd-239-13.el8.x86_64 systemd-libs-239-13.el8.x86_64 systemd-pam-239-13.el8.x86_64 systemd-udev-239-13.el8.x86_64 epel-release-8-5.el8.noarch Removed: grub2-tools-efi-1:2.02-66.el8_0.1.x86_64 Complete!
Reboot the system.
reboot
Verify
Kernel
Very that the system is booted with the old kernel using the below command.
uname -a
Output:
Linux centos8.itzgeek.local 4.18.0-80.el8.x86_64 #1 SMP Tue Jun 4 09:19:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Packages
Compare the version of the package and ensure the packages are downgraded with rpm -qa <package_name>.
Conclusion
That’s All. I hope this post helped you to revert OS patching on CentOS 8 / RHEL 8. Please share your feedback in the comments section.