Table of Contents
In this article, I will take you through different methods through which you can fix broken packages in RHEL/CentOS. Sometimes you might have noticed that whenever you try to run any update or try to install a new package in your RHEL/CentOS Systems, you get broken package error. This error does not allow you to proceed with the update or installation hence causing a road block. While this can happen due to multiple reason, we will see all the possible solution in below section that you can take to solve this error. So without any further delay let's us start !!
What are Broken Packages
Whenever you try to install a list of packages then sometimes it may happen that few of the packages either did not installed properly or get partially installed due to some unexpected reason, those packages are usually called broken packages.
How to Fix Broken Packages in RHEL/CentOS 7/8
Also Read: How to Install VLC Media Player in Debian 11
Method 1: Using rpm command
First you need to verify all the packages with information about the files taken from the package metadata stored in the rpm database using rpm -Va
command as shown below. More about rpm command.
[root@localhost ~]# rpm -Va
.M....... g /var/lib/PackageKit/transactions.db
missing /run/gluster
.M....... g /etc/crypto-policies/back-ends/nss.config
.M....... g /etc/udev/hwdb.bin
.M....... g /var/lib/systemd/random-seed
.M....... d /usr/share/info/dir.old
.M....G.. /var/log/gdm
.M....... c /etc/rc.d/rc.local
.....UG.. g /var/run/avahi-daemon
.M....... g /var/cache/dnf/packages.db
.M....... g /run/dbus
Method 2: Using dnf command
Another method to solve the problem of broken package issue is by running upgrade with -b
option so that it will force dnf to only consider the latest version.
[root@localhost ~]# dnf upgrade -b
CentOS-8 - AppStream 4.3 kB/s | 4.3 kB 00:01
CentOS-8 - AppStream 2.4 MB/s | 9.3 MB 00:03
CentOS-8 - Base 7.3 kB/s | 3.9 kB 00:00
CentOS-8 - Base 1.8 MB/s | 7.5 MB 00:04
CentOS-8 - Extras 1.9 kB/s | 1.5 kB 00:00
CentOS-8 - Extras 13 kB/s | 10 kB 00:00
Dependencies resolved.
If you have any specific broken package then you can try to reinstall that package by using dnf --refresh reinstall package_name
command as shown below.
[root@localhost ~]# dnf --refresh reinstall package_name
Method 3: Using yum command
If you are facing any broken package error while running a yum command then you can try to reinstall all the packages using yum reinstall \*
command.
[root@localhost ~]# yum reinstall \*
Last metadata expiration check: 0:50:37 ago on Sat 16 Oct 2021 02:34:37 AM EDT.
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Reinstalling:
GConf2 x86_64 3.2.6-22.el8 AppStream 1.0 M
adobe-mappings-cmap noarch 20171205-3.el8 AppStream 2.1 M
adobe-mappings-cmap-deprecated noarch 20171205-3.el8 AppStream 119 k
adobe-mappings-pdf noarch 20180407-1.el8 AppStream 707 k
adwaita-cursor-theme noarch 3.28.0-2.el8 AppStream 647 k
If yum is unable to repair then you can skip those packages by using --skip-broken
option.
[root@localhost ~]# yum update --skip-broken
Last metadata expiration check: 0:54:46 ago on Sat 16 Oct 2021 02:34:37 AM EDT.
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Installing:
centos-linux-release noarch 8.4-1.2105.el8 BaseOS 22 k
replacing centos-release.x86_64 8.1-1.1911.0.8.el8
replacing centos-repos.x86_64 8.1-1.1911.0.8.el8
kernel x86_64 4.18.0-305.19.1.el8_4 BaseOS 5.9 M
kernel-core x86_64 4.18.0-305.19.1.el8_4 BaseOS 36 M
kernel-modules x86_64 4.18.0-305.19.1.el8_4 BaseOS 28 M
Upgrading:
PackageKit x86_64 1.1.12-6.el8 AppStream 599 k
Greetings
Step 2 did helped our resolve the yum repository problems
Thank you for sharing
Shalom,
My problem as described was fixed using a combination of Method 2 & Method 3.
Thank you
CD