How to fix yum after CentOS 6 went EOL
by Danila Vershinin, , revisited on
dnf, yum or apt upgrades. It maintains the largest RPM repository of NGINX module packages and Varnish VMODs, with APT packages for Debian and Ubuntu.
Free to install; commercial production use requires a subscription.
If for whatever reason, you are stuck with the now EOL version of the CentOS operating system, you can no longer run yum upgrade successfully. Running yum upgrade in CentOS 6 will yield the following results:
Setting up Upgrade Process
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
Rightfully so, as the YUM repository was removed from the main CentOS update servers, no security or feature upgrades are provided.
However, not all the repositories have halted their support for CentOS 6. The GetPageSpeed repository still provides up-to-date NGINX builds and its module packages.
This may be one reason why you want yum upgrade to still work. Or simply, you are not ready to move on with a newer operating system, and willing to take the security risks associated with using the older version.
How to fix yum upgrade then?
Use the CentOS Vault repository
The CentOS Vault repositories have been around for a long time and allow you to stick to a specific CentOS x.y release even while newer ones are available. Now that there will be no newer 6.x, you can simply point your yum repository configuration to the latest 6.x that will ever be, which is 6.10.
To use the Vault repository, set up its repo configuration instead of the now defunct repositories configuration:
curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo
That’s it, everything should be functional.
Alternatively, you can manually replace the contents of the file /etc/yum.repos.d/CentOS-Base.repo with the necessary configuration.
Copy-paste the entire snippet below and hit Enter:
cat <<-'EOF' > /etc/yum.repos.d/CentOS-Base.repo
[C6.10-base]
name=CentOS-6.10 - Base
baseurl=http://vault.epel.cloud/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never
[C6.10-updates]
name=CentOS-6.10 - Updates
baseurl=http://vault.epel.cloud/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never
[C6.10-extras]
name=CentOS-6.10 - Extras
baseurl=http://vault.epel.cloud/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
metadata_expire=never
[C6.10-contrib]
name=CentOS-6.10 - Contrib
baseurl=http://vault.epel.cloud/6.10/contrib/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
metadata_expire=never
[C6.10-centosplus]
name=CentOS-6.10 - CentOSPlus
baseurl=http://vault.epel.cloud/6.10/centosplus/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
metadata_expire=never
EOF
Now you can run yum upgrade without problems. This also allows you to get to the latest release 6.10 even if you were left behind at, e.g. 6.7.
Not only yum upgrade works, but you can also install arbitrary packages as usual.
Fixing EPEL repository
curl https://www.getpagespeed.com/files/centos6-epel-eol.repo --output /etc/yum.repos.d/epel.repo
Fixing SCLO repositories
The repositories containing newer compilation software like gcc is available via Software Collections.
However, its repositories are likewise gone. Use Vault repositories instead:
yum -y install centos-release-scl
curl https://www.getpagespeed.com/files/centos6-scl-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl.repo
curl https://www.getpagespeed.com/files/centos6-scl-rh-eol.repo --output /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
Running PHP on CentOS 6?
CentOS 6 reached end of life, and its stock PHP 5.3 never got a fix for the critical PHP2Shell vulnerabilities. See PHP2Shell on CentOS 6 for the patched PHP 5.3, 7.0 and 7.1 packages, which update in place with yum once this repository configuration is working.
Want to say thanks?
29 thoughts on “How to fix yum after CentOS 6 went EOL”
Comments are closed.
you save my life
yes
Thank You !
Thanku !! sir !!
It is working for me. !!
I executed “curl https://www.getpagespeed.com/files/centos6-eol.repo –output /etc/yum.repos.d/CentOS-Base.repo”
and I got this error: “curl (35) SSL connect error” Could you please help?
It means your distro is too old to support recent SSL version. Use the manual configuration as mentioned instead of curl command.
Please bear with me. I am very new to this. When I tried to paste the entire snippet, it seemed only the very first line got executed. How to make it execute the entire thing? I am using Putty. Thanks Danila.
Why did you think only the first line was executed? What was the output?
I would like to send you a screenshot. But it looks like this:
[root@sjmrt4 ~]# cat <<-‘EOF’ > /etc/yum.repos.d/CentOS-Base.repo
Instead of copy-pasting as command you can simply edit
/etc/yum.repos.d/CentOS-Base.repoand paste in contents starting from[C6.10-base]tometadata_expire=neverinclusive. That is essentially what the command way does anyway – overwrites the file with the different content.Thank you so much Danila. I will do that. Happy New Year!
Fantastic. Your repos are awesome. Thank you for doing this. Now we can upgrade to CentOS7.
hello,
how do you upgrade to Centos 7 from 6 or RHEL 7 from RHEL 6 ?
Please share.
The answer is that technically you don’t upgrade. CentOS 6 and CentOS 7 are quite different to begin with, example for their usage of different init systems. The best way to go around upgrading is setting up a separate server with CentOS 7 and install/configure the software needed there. The task can be made reproducible with configuration management tools like
ansible.hi,
I been searching for a workaround solution, but it not working.
Some users want to keep their files and applications on the CentOS 6 by not do a fresh installation.
I’ve tried this method, but it didn’t work: redacted
You must do a clean install of CentOS 7 to get it. By spending all that time trying to find a way to upgrade in-place, you could already have “yum install”ed the things you have in CentOS 6.
Don’t waste your time.
Server setup can be done quickly in most cases. Only in rare situations, you need to migrate an app that otherwise won’t work readily in CentOS 7.
Awesome!
Super solution. Thank you very much. We do’nt work alone with you.
Thanks. Really.
TQ BRO…you save my day….
Thanks Danila. Awasome.
I edited the CentOS-Base.repo file as indicated in the directions, copying from [C6.10-base] though metadata_expire=never but I’m getting the following error when I run yum update
[Errno 14] Peer cert cannot be verified or peer cert invalid
Error: cannot retrieve repository metadata (repomd.xml) for repository C6.10-base. Please verify its path and try again.
Any help would be appreciated. Thanks.
You can temporarily add
sslverify=falseto/etc/yum.conf.Everything went well, thanks, guys.
Thank you so much! This worked!
Thank you very much for sharing! This is useful for my sandbox with centos 6 built.
Excellent Solution, worked immediately like a charm, good work Danila and thanks a million !!
I did try adding sslverify=false option into the /etc/yum.conf file but I’m not seeing any change in regards to the error that is appearing
Life saver… dude
you rock!