• 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

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. gnome-calculator: command not found
  2. How to configure resource groups for MySQL Server running on Linux
  3. fprintd-delete Command Examples in Linux
  4. How to Hot-add and Remove Logical Memory in CentOS/RHEL 7
  5. Linux “seq” Command Examples
  6. How to set udev rule for setting the disk permission on ASM disks when using multipath on CentOS/RHEL 6
  7. latte-dock: command not found
  8. blkdiscard: command not found
  9. a2enconf Command Examples in Linux
  10. isosize Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright