CentOS 7.x Use common or shared yum cache among different machines

From Notes_Wiki

Home > CentOS > CentOS 7.x > System Administration > Package management > Yum > CentOS 7.x Use common or shared yum cache among different machines

To avoid downloading packages again from Internet for set of machines that use same OS and similar repos use:

  1. On the main machine where there is enough space in '/var/cache/yum' edit /etc/yum.conf and update
    keepcache=1
  2. Fully update this machine to get updates of all installed packages. The more packages, this machine has the better.
    yum -y update --skip-broken

Now to update any other machine use:

  1. Install sshfs. This is required only once
    yum -y install sshfs
  2. Edit /etc/yum.conf and
    keepcache=1
    This is important else this user machine will end up deleting packages from main gold machine after update. We can leave the setting as it is after update to be safe. Cleaning cache from normal user machine is easier then building cache on gold-machine.
  3. Mount gold machine /var/cache/yum on this machine using sshfs
    sshfs root@<gold-machine>:/var/cache/yum/ /var/cache/yum
    Type password as necessary
    Note that these steps suggest use of sshfs as it is easy for small number of machines (<5). Based on your scenario you might want to share over NFS or CIFS.
  4. Use "df -h" and verify that remote cache is mounted locally
  5. Use following to update the normal user machine using remote cache:
    yum -y update --skip-broken
  6. umount /var/cache/yum/


If the setup is quite large (>100 machines) then you should consider setting up a proper local repository using Createrepo

To delete older copies of same package from gold-machine refer to Script to delete older versions of rpm files from cache


Home > CentOS > CentOS 7.x > System Administration > Package management > Yum > CentOS 7.x Use common or shared yum cache among different machines