• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

“yum clean all” not clearing yum repository cache in CentOS/RHEL/OEL

by admin

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 

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux, OEL 6, OEL 7

Some more articles you might also be interested in …

  1. chgrp: command not found
  2. compsize: command not found
  3. htpdate Command Examples in Linux
  4. diff: command not found
  5. How to obtain virtual/physical CPU information in Oracle VM (XEN)
  6. How to add Swap Space on Linux Servers (CentOS/RHEL) On the Fly
  7. CentOS / RHEL : How to configure an DHCP server
  8. How to view linux disk partitions (partition table)
  9. Starting iptables Fails with Error “Another app is currently holding the xtables lock”
  10. vshadowmount: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright