Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]


Rocky Linux

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

  1. Upgrade CentOS 7 to CentOS 8
  2. 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

Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]

It then checks the installed packages on the server and system packages.

Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]

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.

Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]

 

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.

Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]

 

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.

 

Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

21 thoughts on “Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]”

    • 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.

      Reply
  1. 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.

    Reply
    • 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.

      Reply
  2. 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?

    Reply
  3. Needed to switch from mirrors to vault repository.

    sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-*
    sed -i 's|#baseurl=http://mirror\.centos\.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
    Reply
  4. 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?

    Reply
    • 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.

      Reply
  5. Lovely article but I’m stuck at “Install CentOS 8 YUM repositories” I get :-

    Last metadata expiration check: 0:15:09 ago on Tue 09 Aug 2022 13:21:29 BST.
    [MIRROR] centos-linux-repos-8-2.el8.noarch.rpm: Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-linux-repos-8-2.el8.noarch.rpm
    [FAILED] centos-linux-repos-8-2.el8.noarch.rpm: Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-linux-repos-8-2.el8.noarch.rpm
    Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-linux-repos-8-2.el8.noarch.rpm

    Have tried https – same result.

    I’m on CentOS 7.9

    Reply
  6. I’m getting an error:

    Error:
     Problem: cannot install the best update candidate for package platform-python-devel-3.6.8-38.el8_4.x86_64
      - nothing provides python3-libs(x86-64) = 3.6.8-38.el8_4.rocky.1 needed by platform-python-devel-3.6.8-38.el8_4.rocky.1.x86_64
    (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

    Error during distro-sync.

    Reply

Leave a Comment