How to enable yum on CentOS-5.x


How to enable yum on CentOS-5.x

yum command error on CentOS-5.x

If you got yum command error on CentOS-5.x and it's not network issue, package repository for CentOS-5.x has already been removed from CentOS official repository.

How to re-enable yum command on CentOS-5.x

Support period of CentOS-5.x ended already, therefore packages have already been deleted from CentOS official package repository, but snapshot of the deleted packaged are kept at http://vault.centos.org/ website. So we need to point to the http://vault.centos.org/ website in yum setting file.




What is http://vault.centos.org/

According to http://vault.centos.org/readme.txt, the website keeps archive files of older CentOS versions. However, it doesn't provide software security patches, so only snapshots are provided at the website.

You can see which CentOS versions are kept at the http://vault.centos.org/

Change yum setting file to point to the vault.

First off, we need to change yum setting file to point to the http://vault.centos.org/ website.

We need to take a backup of /etc/yum.repos.d/CentOS-Base.repo file just in case.
$ sudo cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.BACKUP

Then, we need to open /etc/yum.repos.d/CentOS-Base.repo file and rewrite yum setting as follows.
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://vault.centos.org/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
baseurl=http://vault.centos.org/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://vault.centos.org/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://vault.centos.org/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

Please save the file and run the following command, so that you should be able to use yum command again without any issues.
$ sudo yum update