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?
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.
[base] ... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://vault.centos.org/$releasever/os/$basearch/ ... [updates] ... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://vault.centos.org/$releasever/updates/$basearch/ ... [extras] ... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://vault.centos.org/$releasever/extras/$basearch/ ... [centosplus] ... #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=http://vault.centos.org/$releasever/centosplus/$basearch/ ...
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.