Make Yum use specific package version from CentOS vault

Sometimes for a specific reason you want to use certain CentOS version which is removed from the main tree. Trying to update packages will report that packages for your version do not exist, but there is a way to fix this.

If you tweak the Yum repository files and remove mirrorlist directives and enable baseurl directives instead you will be able to download packages just for that specific release.

For example replace:




Where 7.3.1611 is the specific version.

If you installed some older version of CentOS which is now moved from the main tree to the vault, you could use following script to automatically tweak all Yum repository files.

RELEASE='grep -oE '[0-9]+\.[0-9]+\.[0-9]+' /etc/centos-release'
mkdir -p /etc/yum.repos.original.d
cp -r /etc/yum.repos.d /etc/yum.repos.original.d
cd /etc/yum.repos.d
sed -i 's/^mirrorlist=/###mirrorlist=/' *
sed -i 's/^#baseurl=/baseurl=/' *
sed -i '/^baseurl/$$RELEASE%' *

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.