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

The Geek Diary

CONCEPTS | BASICS | HOWTO

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

How to change the default location (/var/cache/yum) of yum cache

By admin

The cachedir specifies the directory where yum stores downloaded packages, although with keepcache set to 0, yum does not store these packages after installing them. Consider a case where the /var filesystem where yum cache is located is full and there is no diskspace for yum to download the system updates. Also, you do not have set the keepcache variable to 0. The “yum install” command would end up with the error like:

insufficient space in download directory /var/cache/yum/rhel-x86_64-server-6/packages

You always have an option to clean the yum cache using the below post.

How to clean YUM cache in CentOS / RHEL

But, if you do not want to go that way and want to change the default cache location itself, then follow the steps outlined below.

Changing the location of yum cache from the default /var/cache/yum

1. The yum cache location is configured in /etc/yum.conf file as cachedir option in the [main] section and can be changed:

# cat /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever

As per the man page for yum.conf:

# man yum.conf
[main] OPTIONS
The [main] section must exist for yum to do anything. It consists of the following options:
    cachedir Directory where yum should store its cache and db files. The default is `/var/cache/yum'.

2. Let’s assume that you want the yum cache location to be a new directory called /yum_cache. Make appropriate changes to the /etc/yum.conf file as shown below for changing the default cache location.

# cat /etc/yum.conf 
[main]
cachedir=/yum_cache/$basearch/$releasever

Although you can change the location of yum cache anytime, it is recommended to check and clean /var volume, or, in case all the files on it are needed, to increase the volume size.

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

Some more articles you might also be interested in …

  1. Troubleshooting Common GUI / X-Window Issues on CentOS/RHEL
  2. How to resize (extend) a partition-based file system in Linux
  3. CentOS / RHEL 7 : Never run the iptables service and FirewallD service at the same time!
  4. Linux OS Service ‘setroubleshoot’
  5. How to automate sftp file transfers using expect utility
  6. How to Trace Python Scripts using trace.py
  7. How to disable the default apache “Welcome Page” in CentOS/RHEL 7
  8. How to schedule Jobs with Cron in Linux
  9. CentOS / RHEL : Move a Physical Volume from an existing Volume Group to another Volume Group
  10. How to Configure ACL(Access Control Lists) in Linux FileSystem

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary