Are you stranded on what Operating System to migrate to from CentOS? In this guide, we shall describe how one can migrate from CentOS X to Rocky Linux 8 along with all the data (no data loss). Rocky Linux is a community enterprise operating system created to be 100% bug-for-bug compatible with Red Hat Enterprise Linux.
Rocky Linux 8.9, codenamed Green Obsidian, is the stable version of Rocky Linux released on 2023-11-22
This Operating system is 100% bug-for-bug compatible with RedHat Enterprise Linux 8.9 which was released on 2023-11-14. This makes it a perfect alternative for CentOS users who would wish to continue using stable RPM-based Linux systems.
For us to migrate to Rocky Linux 8.9, we need to upgrade our existing CentOS X servers to CentOS 8, before we can migrate to Rocky Linux. This is for compatibility purposes in terms of the RHEL versions and Kernel versions.
We shall demonstrate how to migrate from CentOS 7 and CentOS 8 to Rocky Linux. There is no direct way to migrate from CentOS 7 to Rocky Linux 8. This is because Rocky Linux is only compatible with RHEL 8 and its subsidiaries. This means that to migrate from CentOS 7 to Rocky Linux 8, we will first need to upgrade CentOS 7 to CentOS 8 otherwise you may encounter an error such as
This script must be run on an EL8 distribution. Migration from other distributions is not supported. An error occurred while we were attempting to convert your system to Rocky Linux. Your system may be unstable. Script will now exit to prevent possible damage.
We will follow the steps below to successfully migrate from CentOS 7 to Rocky Linux 8.9
- Upgrade CentOS 7 to CentOS 8
- Migrate from CentOS 8 to Rocky Linux
Steps to Migrate CentOS 7 or 8 to Rocky Linux 8
Pre-requisites
There are certain pre-requisites before you start with the migration
- Make sure your root file system has atleast 30 GB free space. During the migration process multiple rpms will be installed and updated which will need enough space on the root file system. You can check the available space of your root file system using
df -h /
- You will need an active internet connection. Since the major part of the migration involves installing packages, we will do this directly from online repositories. Alternatively you may configure offline repositories and then use that repo in your private network for performing the migration.
- Backup your existing data. Although we assume that there will be no data loss but it is always a good idea to backup your file system.
Step 1. Upgrade CentOS 7 to CentOS 8
This is quiet tedious step and there are high chances that one or the other thing can go wrong. Recently thanks to some users I was informed that the procedure I had shared was not up to date and hence I decided to move this section completely into a new article which can be only dedicated for upgrade.
So you can refer How to upgrade CentOS 7 to 8 PROPERLY and get back to this article once you have successfully upgraded to CentOS 8.
Step 2. Download Migration Script
Download the official script from Rocky Linux that will be used for the migration. This script is available on GitHub. You can download using the wget
command.
$ wget https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh
Provide executable permission to this script:
# chmod u+x migrate2rocky.sh
Step 3. Initiate the migration from CentOS 8 to Rocky Linux 8
Run the downloaded script with sudo permission or as root user to start the migration process from CentOS 8 to Rocky Linux 8.
# ./migrate2rocky.sh -r
The script starts by determining the repository names configured on the server
It then checks the installed packages on the server and system packages.
The script will then initialize the download of packages from Rocky Linux repo. The overall execution of this script may take some time depending upon your system resources.
When the package installation is done, you will be prompted to reboot your system.
Step 4. Reboot system to activate Rocky Linux 8
Reboot your system into your new Rocky Linux environment.
# reboot
After the successful reboot, you will be presented with a Rocky Linux environment upon reboot. Login with the same credentials you used on CentOS environment.
Step 5. Verify data status post successful migration
To verify that you have not lost any of your data after successful migration from CentOS to Rocky Linux 8.9, check the OS-Release version;
[root@centos-7 ~]# cat /etc/os-release NAME="Rocky Linux" VERSION="8.9 (Green Obsidian)" ID="rocky" ID_LIKE="rhel centos fedora" VERSION_ID="8.9" PLATFORM_ID="platform:el8" PRETTY_NAME="Rocky Linux 8.9 (Green Obsidian)" ANSI_COLOR="0;32" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:rocky:rocky:8:GA" HOME_URL="https://rockylinux.org/" BUG_REPORT_URL="https://bugs.rockylinux.org/" SUPPORT_END="2029-05-31" ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8" ROCKY_SUPPORT_PRODUCT_VERSION="8.9" REDHAT_SUPPORT_PRODUCT="Rocky Linux" REDHAT_SUPPORT_PRODUCT_VERSION="8.9" [root@centos-7 ~]# cat /etc/redhat-release Rocky Linux release 8.9 (Green Obsidian)
The above output verifies that we are running on the latest version of Rocky Linux, which is 8.9.
You can also verify that your applications still exist:
## Verify php $ php -v PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies ## Verify MySQL $ mysql -V mysql Ver 15.1 Distrib 10.3.28-MariaDB, for Linux (x86_64) using readline 5.1 ## Verify Apache $ httpd -v Server version: Apache/2.4.37 (rocky) Server built: Jun 11 2021 15:35:05
As you can see all our application data is intact and we have successfully migrated from CentOS 7 to Rocky Linux 8.
Conclusion
In this article, we have demonstrated step by step instructions to migrate from Centos 7 & 8 to Rocky Linux 8.9. I hope the steps are clear and you can easily follow them. Feel free to reach out in case you encounter any problems.
You can also refer Transition from CentOS to Rocky for more information.
the title suggest it’s working 100%, but it’s unfortunately not. I’m running CentOS 7 , and it fails with the repo, eg.
dnf install https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-3.el8.noarch.rpm
Problem: package centos-gpg-keys-1:8-3.el8.noarch conflicts with centos-release < 8.0-0.1905.0.10 provided by centos-release-7-9.2009.1.el7.centos.x86_64
I apologise for this, the article was written quiet some time back and was not updated lately. Based on your feedback I have retested the complete procedure and updated the article wherever required. I have also written another article to perform CentOS 7 to 8 upgrade as that required multiple steps and I thought it was best to keep these two articles isolated.
after doing all the process from upgrading centos 7 to centos 8 dint work properly throwing dnf -y upgrade error, after rebooting still stays in the same version centos 7.9.2009 not able to upgrade tried multiple methods each time showing different errors.
The content from this article was outdated and was not working. Can you refer perform CentOS 7 to 8 upgrade which I have written after performing a successful upgrade from CentOS 7.6 to 8.5. You can report any error in the respective article and I will happy to help in any way I can.
I’m not understanding what I’m to do with the results returned by package-cleanup –leaves and package-cleanup –orphans.
If I do a yum remove for the first of the packages listed by the –leaves option the package appears to be removed, but when I do a package-cleanup –leaves again, the package is still listed! Am I just not understanding something?
Needed to switch from mirrors to vault repository.
This is the latest repo for centos 8
dnf install https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm,centos-gpg-keys-8-3.el8.noarch.rpm}
Got into trouble – system did not have enough space in /, so process of converting Centos 8 -> Rocky 8 failed. Cleared some space, but now script is complaining “Found a full or partial RockyLinux install already in place. Aborting” Is there a way out of this?
Replying to myself in case somebody else runs into the same situation.
I was able to run ‘dnf update’ and rebooted. Turned out that system was missing grub.conf, so I ended up booting at the grub prompt level. Was able to boot manually and ran ‘grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg’. Should have run this command before rebooting but I did not realize that the file was missing at that time.
Lovely article but I’m stuck at “Install CentOS 8 YUM repositories” I get :-
Have tried https – same result.
I’m on CentOS 7.9
This is 404 which woud mean package is not available on that mirror but then you mentioned you are on CentOS 7.9 but the repo URL is from CentOS 8
The article shows the need to upgrade to CentOS 8 and appears to give instructions on how to do so – unless I’ve misundertood! Turns out that the CentOS 8 went EOL last year and all the “files” have been archived. I’ve seen a link to another mirror but haven’t tried it yet. I like your article and think that I should be able to migrate to Rocky if I can do the update to CentOS 8.
I’ll keep looking Thank you
same here, mirror org removed the directory//
You may try this base link: http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/
I found the vault and this command works.
dnf install https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-3.el8.noarch.rpm,centos-linux-release-8.5-1.2111.el8.noarch.rpm, centos-gpg-keys-8-3.el8.noarch.rpm}
Thanks Trevor,
Is that all one command?
Just to confirm, will that update my CentOS 7.9.2009 to 8.5 ?
Will I then be able to migrate to Rocky using the scripts?
Thanks in advance.
Jeff
This will need updating now that Centos 8 is EOL and the repos have been moved into archive.
Thanks for the HINT, we will get the steps verified based on available repo status and update the article
I did a
sudo dnf update --nobest
And then magic happened.
It worked.
Thank You for sharing!
I’m getting an error:
Error during distro-sync.