The Problem
“Yum clean all” not clearing the yum cache information under /var/cache/yum for orcle Linux server which use Oracle public yum repository or local yum repository.
# yum repolist Loaded plugins: refresh-packagekit, security, ulninfo public_ol6_UEK_latest | 1.2 kB 00:00 public_ol6_UEK_latest/primary | 26 MB 00:04 public_ol6_UEK_latest 554/554 public_ol6_latest | 1.4 kB 00:00 public_ol6_latest/primary | 58 MB 00:04 public_ol6_latest 36051/36051 repo id repo name status public_ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Ser 554 public_ol6_latest Oracle Linux 6Server Latest (x86_64) 36,051 repolist: 36,605
# du -sh /var/cache/yum/x86_64/6Server/* 864K /var/cache/yum/x86_64/6Server/ol6_addons 973M /var/cache/yum/x86_64/6Server/ol6_latest 367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_latest 8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest 45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest
# yum clean all Loaded plugins: refresh-packagekit, security, ulninfo Cleaning repos: public_ol6_UEK_latest public_ol6_latest Cleaning up Everything
# du -sh /var/cache/yum/x86_64/6Server/* 864K /var/cache/yum/x86_64/6Server/ol6_addons 973M /var/cache/yum/x86_64/6Server/ol6_latest 367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_latest 8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest 45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest
The Solution
“yum clean” removes the cache of repositories which are enabled in /etc/yum.repos.d/*.repo. From the man page of yum:
# man yum .... CLEAN OPTIONS The following are the ways which you can invoke yum in clean mode. Note that "all files" in the commands below means "all files in currently enabled repositories". If you want to also clean any (temporarily) disabled repositories you need to use --enablerepo=’*’ option.
Follow the steps below to troubleshoot:
1. Enable the repositories temporarily to clear the yum cache.
# yum clean all --enablerepo="repository_label"
or
# vi /etc/yum.repos.d/[filename].repo ... enabled = 1 ### Add this for the respective repository.
What if, there is no information about the repository in /etc/yum.repos.d/*.repo file? In that scenario, a temporary entry on the repository file with the repository label name, will help to clear the cache.
Debugging
In the following example, only two repositories are enabled i.e “public_ol6_UEK_latest, public_ol6_latest”, whereas the yum cache information’s are available for few additional repository.
Let’s assume “public_ol6_UEKR3_latest” repository is disabled and “ol6_UEK_latest, ol6_latest” doesn’t have entry in /etc/yum.repos.d/*.repo file.
# yum repolist Loaded plugins: refresh-packagekit, security, ulninfo public_ol6_UEK_latest | 1.2 kB 00:00 public_ol6_UEK_latest/primary | 26 MB 00:04 public_ol6_UEK_latest 554/554 public_ol6_latest | 1.4 kB 00:00 public_ol6_latest/primary | 58 MB 00:04 public_ol6_latest 36051/36051 repo id repo name status public_ol6_UEK_latest Latest Unbreakable Enterprise Kernel for Oracle Linux 6Ser 554 public_ol6_latest Oracle Linux 6Server Latest (x86_64) 36,051 repolist: 36,
# du -sh /var/cache/yum/x86_64/6Server/* 864K /var/cache/yum/x86_64/6Server/ol6_addons 973M /var/cache/yum/x86_64/6Server/ol6_latest 367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_latest 8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest 45MB /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest
Clear the cache information of the disabled repository which has an entry in /etc/yum.repos.d/*.repo file. i.e. public_ol6_UEKR3_latest:
# yum clean all --enablerepo="public_ol6_UEKR3_latest"
# du -sh /var/cache/yum/x86_64/6Server/* 864K /var/cache/yum/x86_64/6Server/ol6_addons 973M /var/cache/yum/x86_64/6Server/ol6_latest 367M /var/cache/yum/x86_64/6Server/ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_latest 8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest
To clear the cache of two other repository which doesn’t have entry in “/etc/yum.repos.d/*.repo”, it can be removed manually or add a temporary entry on config file.
# rm -rf /var/cache/yum/x86_64/6Server/ol6_latest /var/cache/yum/x86_64/6Server/ol6_latest
Or
# vi /etc/yum.repos.d/public.repo [ol6_latest] enabled = 1 [ol6_UEK_latest] enabled = 1
# yum clean all
# du -sh /var/cache/yum/x86_64/6Server/* 864K /var/cache/yum/x86_64/6Server/ol6_addons 12.0K /var/cache/yum/x86_64/6Server/ol6_latest 8.0K /var/cache/yum/x86_64/6Server/ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_latest 8.0K /var/cache/yum/x86_64/6Server/public_ol6_UEK_latest 12K /var/cache/yum/x86_64/6Server/public_ol6_UEKR3_latest