How to Upgrade CentOS to a Specific Version

Sometimes, especially for Windows Administrators, upgrading CentOS (or any other flavor of Linux, for that matter) can feel a bit like a holdup, and you’re the poor fool behind the register at the convenience store.

Sure, it can be as easy as:

$ yum upgrade

And you’re off to the races, upgrading your CentOS to the latest version, easy as pie.

But what if you don’t want to jump all the way to the latest version, or you have something installed (or a piece of hardware) that is not yet compatible with the latest release?

Repository Tricks

It’s time to invoke some repository tricks.  The short version is that you need to tell yum to get the right release (version) of the packages to upgrade the OS.  It’s pretty simple, on the surface:

$ yum upgrade --releasever=7.3.1611

For Red Hat Enterprise Linux (RHEL), that really is all you need to do, because it will hunt down the right repository and spring into action.

CentOS, however, only hosts the latest version of the OS on their repository mirrors, so you’ll get the following helpful message:

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.

Break into the Vault

Luckily, CentOS does offer all of their versions (seriously, like all of them) on their vault repository.  All you need to do to make the above command work is modify the yum configuration file to point that the vault repo instead of the standard mirror.

Comment out the mirrorlist and then add the baseurl in each section of the config file.  Note that the default baseurl won’t do the job, so create a new one instead.


And there you have it.  Now, run the yum command again, and you’ll be in business!

By the way, if you want to peek at the vault and check out what versions they have hiding in there (or you simply don’t know what the exact version numbers are and need to look them up, like me), just browse the vault:

Assuming you don’t need to do this all the time, you might want to undo the changes to the CentOS-Base.repo file, but if you plan to be very gentle with this server and always carefully update it to something other than the latest version, then just leave the config file as is.

– John

Oh, and that image above is spot on.  Linux Admins are crazy!  I kid… mostly.    Thanks to my Linux Admin buddy, Paul, for helping me nail this down.

5 thoughts on “How to Upgrade CentOS to a Specific Version

  1. Thanks for the article, it was very helpful. One thing that I found is $releasever in the repos did not appear to work. The error at the end of this reply is what I got. It seems that it only took the first digit of the version string. The command I used was: yum -y update –releasever=7.4.1708. To get around the issue I hard code the release version in the repo file. [Errno 14] HTTP Error 404 – Not Found


    1. Thanks, Charles. That’s good to know. If anyone has another workaround for this (or alternate syntax that looks at more than the first character of the version string) please post a reply.


    2. Hello Charles,
      i know this is not a recent thread, but may you be more specific?
      Might you indicate the exact correction you did on the repo file?


      1. Andrew, in case Charles isn’t following this thread anymore, my guess is that he changed this:
        to something like this:

        Charles, if you’re still “listening” please feel free to weigh in and confirm or deny my guess! That said, it’s still odd because I’m not sure why the variable wouldn’t work just as well as a hard-coded string of numbers.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s