Skip to content

Instantly share code, notes, and snippets.

@zekome
Last active April 11, 2022 12:04
Show Gist options
  • Save zekome/42db5896c85fbe8f18108b809623ef97 to your computer and use it in GitHub Desktop.
Save zekome/42db5896c85fbe8f18108b809623ef97 to your computer and use it in GitHub Desktop.

Upgrade CentOS after EOL to Rocky Linux or CentOS Stream

When you try to install using package manager on CentOS Linux after EOL date (December 31, 2021) you'll get an error:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

That's because repositories have been moved to centos project vault location. A way to handle is to point urls from repos configuration to centos vault location. Then it's possible to update CentOS (for example, from previous version 8.4.2105) to the latest version 8.5.2111. From there you could shift towards Rocky Linux or CentOS Stream following recommended procedure.

Do everything in tmux terminal in case you are doing this remotely. The connection can be lost in the middle of work, leaving an upgrade possible in non recoverable state.

Update CentOS repos and install tmux

sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo 
sed -i 's|^#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|' /etc/yum.repos.d/*.repo
dnf -y install tmux

Start tmux session

tmux new -s upgrade

Update CentOS to 8.5.2111 first

dnf -y update

Option 1) Switch to Rocky Linux

cd /usr/local/src
curl https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh -o migrate2rocky.sh
bash migrate2rocky.sh -r

Option 2) Switch to CentOS Stream

dnf -y install centos-release-stream
dnf -y swap centos-{linux,stream}-repos
dnf -y distro-sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment