User Tools

Site Tools


os:linux:distributions:centos:notes:setfixedrpmrepositories

OS - Linux - Distributions - CentOS - Notes - Set fixed RPM repositories

In some cases it is useful to change the default RPM repository mechanism of using a dynamic mirrorlist to a fixed mirrorlist.

For example when policy is to not allow direct http to all hosts on the Internet from the internal servers setting fixed RPM repositories will allow you to open http(s) to a limited number of IP addresses for CentOS package updates.

Rocky Linux 8

Rocky Linux 8 repositories

For the Rocky Linux 8 default repositories:

  1. Check if the .repo files are still set to the default:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/Rocky-*.repo
  2. If all .repo files except Media stil have lines starting with mirrorlist instead of #mirrorlist and #baseurl instead of baseurl, then the mirrorlists are active.
  3. Make a back-up copy of the .repo files:
    mkdir /root/yum.repos.d-backup/
    cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
  4. Disable the lines starting with mirrorlist (^mirrorlist) by prefixing mirrorlist with a #:
    sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/Rocky-{AppStream,BaseOS,Debuginfo,Devel,Extras,HighAvailability,NFV,Plus,PowerTools,ResilientStorage,RT,Sources}.repo
  5. Enable the baseurl lines by removing the # prefix and setting the baseurl to https://ftp.nluug.nl:
    sed -i 's/^#baseurl=http:\/\/dl.rockylinux.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/rocky/' /etc/yum.repos.d/Rocky-{AppStream,BaseOS,Debuginfo,Devel,Extras,HighAvailability,NFV,Plus,PowerTools,ResilientStorage,RT,Sources}.repo
  6. Check if the .repo files have changed:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/Rocky-*.repo
  7. Clean and re-download the package cache/metadata:
    dnf clean all && dnf makecache
  8. [Optional] Disable the dnf-makecache.timer that runs every hour (and refreshes the cache every 3 hours):
    systemctl stop dnf-makecache.timer
    systemctl disable dnf-makecache.timer

Sources:

CentOS 8

CentOS 8 repositories

For the CentOS 8 default repositories:

  1. Check if the .repo files are still set to the default:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
  2. If all .repo files except Debuginfo, Media, and Sources stil have lines starting with mirrorlist instead of #mirrorlist and #baseurl instead of baseurl, then the mirrorlists are active.
  3. Make a back-up copy of the .repo files:
    mkdir /root/yum.repos.d-backup/
    cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
  4. Disable the lines starting with mirrorlist (^mirrorlist) by prefixing mirrorlist with a #:
    1. CentOS 8.3:
      sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-Linux-{AppStream,BaseOS,ContinuousRelease,Devel,Extras,FastTrack,HighAvailability,Plus,PowerTools}.repo
    2. CentOS 8.2:
      sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-{AppStream,Base,centosplus,CR,Devel,Extras,fasttrack,HA,PowerTools}.repo
  5. Enable the baseurl lines by removing the # prefix and setting the baseurl to https://ftp.nluug.nl:
    1. CentOS 8.3:
      sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-Linux-{AppStream,BaseOS,ContinuousRelease,Devel,Extras,FastTrack,HighAvailability,Plus,PowerTools}.repo
    2. CentOS 8.2:
      sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-{AppStream,Base,centosplus,CR,Devel,Extras,fasttrack,HA,PowerTools}.repo
  6. Check if the .repo files have changed:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
  7. Clean and re-download the package cache/metadata:
    dnf clean all && dnf makecache
  8. [Optional] Disable the dnf-makecache.timer that runs every hour (and refreshes the cache every 3 hours):
    systemctl stop dnf-makecache.timer
    systemctl disable dnf-makecache.timer

Sources:

EPEL

For the EPEL repository installed with:

dnf install epel-release
  1. Check if the .repo files are still set to the default:
    egrep "^metalink|^baseurl|^#metalink|^#baseurl" /etc/yum.repos.d/epel*.repo
  2. If all EPEL .repo files have lines starting with metalink instead of #metalink and #baseurl instead of baseurl, then the metalinks are active.
  3. Make a back-up copy of the .repo files:
    mkdir /root/yum.repos.d-backup/
    cp -p /etc/yum.repos.d/epel*.repo /root/yum.repos.d-backup/
  4. Disable the lines starting with metalink (^metalink) by prefixing metalink with a #:
    sed -i 's/^metalink/#metalink/' /etc/yum.repos.d/epel*.repo
  5. Enable the baseurl lines by removing the # prefix and setting the baseurl to https://ftp.nluug.nl:
    1. CentOS 8:
      sed -i 's/^#baseurl=https:\/\/download.fedoraproject.org\/pub\/epel/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/fedora-epel/' /etc/yum.repos.d/epel*.repo
    2. CentOS 7:
      sed -i 's/^#baseurl=http:\/\/download.fedoraproject.org\/pub\/epel/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/fedora-epel/' /etc/yum.repos.d/epel*.repo
  6. Check if the .repo files have changed:
    egrep "^metalink|^baseurl|^#metalink|^#baseurl" /etc/yum.repos.d/epel*.repo
  7. Clean and re-download the package cache/metadata:
    dnf clean all && dnf makecache

CentOS 7

CentOS 7 repositories

For the CentOS 7 default repositories:

  1. Check if the .repo files are still set to the default:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
  2. If all .repo files except Debuginfo, Media, and Sources stil have lines starting with mirrorlist instead of #mirrorlist and #baseurl instead of baseurl, then the mirrorlists are active.
  3. Make a back-up copy of the .repo files:
    mkdir /root/yum.repos.d-backup/
    cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
  4. Disable the lines starting with mirrorlist (^mirrorlist) by prefixing mirrorlist with a #:
    sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
  5. Enable the baseurl lines by removing the # prefix and setting the baseurl to https://ftp.nluug.nl:
    sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/centos/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
    1. To change to vault.centos.org for a specific older version (7.7.1908 in this example):
      1. sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/centos\/\$releasever/baseurl=https:\/\/vault.centos.org\/7.7.1908/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
      2. And disable the yum fastestmirror plugin:
        sed -i 's/enabled\=1/enabled\=0/' /etc/yum/pluginconf.d/fastestmirror.conf
  6. Check if the .repo files have changed:
    egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
  7. Clean and re-download the package cache/metadata:
    yum clean all && yum makecache
os/linux/distributions/centos/notes/setfixedrpmrepositories.txt · Last modified: 2022/02/15 14:17 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki