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

Migrate CentOS 7 or 8 to Rocky Linux 8

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.4, codenamed Green Obsidian, is the stable version of Rocky Linux released after Rocky Linux 8.3 RC1 (Release Candidate 1).

Advertisement

This Operating system is 100% bug-for-bug compatible with RedHat Enterprise Linux 8.4. 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.4, 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.

We will follow the steps below to successfully migrate from CentOS 7 to Rocky Linux 8.4

  1. Upgrade CentOS 7 to CentOS 8
  2. Migrate from CentOS 8 to Rocky Linux

 

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

The purpose of this step is to upgrade CentOS 7 servers to a Rocky Linux compatible version of CentOS which is CentOS 8.4. This exercise will also ensure that we don’t lose any data and configurations in our existing environment.

Advertisement

In this guide, we shall be upgrading a CentOS 7 server running LAMP stack. Follow the steps below to upgrade your CentOS 7 server to CentOS 8.

 

1.1: Gather System Information

Gather the necessary information on your CentOS 7 instance. This will help us in the upgrade process and also for troubleshooting purposes in case we run into a problem during the upgrade.

Check the Kernel version

# uname -r
3.10.0-1160.36.2.el7.x86_64

Check the version of running applications. In our case, LAMP

For Apache:

# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 16 2020 16:18:20

For PHP

# php -v
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

For MySQL

# mysql -V
mysql  Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1

 

1.2: Install EPEL-Release

Install epel-release to allow you to download packages that are not available at CentOS-Base repositories.

Advertisement
# yum install epel-release -y

 

1.3: Install Required Packages

Install the following packages which are needed for the subsequent step

# yum install -y yum-utils rpmconf

 

1.4: Remove Conflicting and Unused Packages/Configurations

Locate and remove conflicting files using the rpmconf tool we downloaded in the previous step.
Migrate CentOS 7/8 to Rocky Linux 8 [100% Working]

List the packages that are no longer needed on your system

# package-cleanup --leaves

List duplicate packages

# package-cleanup --orphans

Remove the packages that have been listed in the above commands

# yum remove -y <package>

 

1.5: Upgrade from YUM to DNF

Download and install DNF package manager, which is the default package manager for CentOS 8.

# yum install -y dnf

Remove YUM package manager from your system since it is no longer needed.

# dnf remove -y yum yum-metadata-parser

Delete the YUM configurations

# rm -Rf /etc/yum

Lastly, build cache for DNF repositories

# dnf makecache

 

1.6: Upgrade CentOS 7 Packages

Our CentOS 7 instance is now ready to be upgraded to CentOS 8. Before we can do that, we should make sure that CentOS 7 packages are up-to-date. To do that, upgrade them with the command below:

# dnf upgrade -y

Last metadata expiration check: 0:03:49 ago on Fri 06 Aug 2021 02:47:16 PM EAT.
Dependencies resolved.
=========================================================================================================
 Package                       Arch                    Version               Repository             Size
=========================================================================================================
Upgrading:
 epel-release                  noarch                  7-13                  epel                   15 k

Transaction Summary
=========================================================================================================
Upgrade  1 Package

Total download size: 15 k
Downloading Packages:
epel-release-7-13.noarch.rpm                                              53 kB/s |  15 kB     00:00    
---------------------------------------------------------------------------------------------------------
Total                                                                    5.7 kB/s |  15 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                 1/1 
  Upgrading        : epel-release-7-13.noarch                                                        1/2 
  Cleanup          : epel-release-7-11.noarch                                                        2/2 
  Verifying        : epel-release-7-13.noarch                                                        1/2 
  Verifying        : epel-release-7-11.noarch                                                        2/2 

Upgraded:
  epel-release-7-13.noarch                                                                               

Complete!

 

1.8: Install CentOS 8 YUM repositories

We will then need to install the CentOS 8 YUM repos. This can be done as follows:

# dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm,centos-gpg-keys-8-2.el8.noarch.rpm}

Extra Packages for Enterprise Linux 7 - x86_64                           2.6 MB/s |  17 MB     00:06    
Last metadata expiration check: 0:00:03 ago on Fri 06 Aug 2021 02:59:55 PM EAT.
centos-linux-repos-8-2.el8.noarch.rpm                                     35 kB/s |  20 kB     00:00    
centos-linux-release-8.4-1.2105.el8.noarch.rpm                            75 kB/s |  22 kB     00:00    
centos-gpg-keys-8-2.el8.noarch.rpm                                        59 kB/s |  12 kB     00:00    
Dependencies resolved.
=========================================================================================================
 Package                        Arch             Version                    Repository              Size
=========================================================================================================
Installing:
 centos-linux-repos             noarch           8-2.el8                    @commandline            20 k
 centos-linux-release           noarch           8.4-1.2105.el8             @commandline            22 k
     replacing  centos-release.x86_64 7-9.2009.1.el7.centos
 centos-gpg-keys                noarch           1:8-2.el8                  @commandline            12 k

Transaction Summary
=========================================================================================================
Install  3 Packages

...

Installed:
  centos-linux-repos-8-2.el8.noarch              centos-linux-release-8.4-1.2105.el8.noarch             
  centos-gpg-keys-1:8-2.el8.noarch              

Complete!

Also update the EPEL-Release repo as shown below:

# dnf upgrade -y epel-release

 

1.8: Upgrade CentOS 7 to CentOS 8

To upgrade to CentOS 8;

Remove old CentOS Kernels

# rpm -e `rpm -q kernel` --nodeps

Remove any conflicting packages

# rpm -e --nodeps sysvinit-tools

Launch CentOS 8 system upgrade

# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync

Install the new CentOS 8 Kernel Core.

# dnf install -y kernel-core

Install CentOS 8 minimal package

# dnf -y groupupdate "Core" "Minimal Install"

After a successful installation, reboot your system to load the new kernel

# systemclt reboot

Verify that your system has upgraded successfully and that you still have your applications.

$ cat /etc/redhat-release
CentOS Linux release 8.4.2105

With this, we can now confirm that we have successfully upgraded from CentOS 7 to CentOS 8.

 

After a successful upgrade from CentOS 7 to CentOS 8, let’s now proceed to the next step which is the migration process. This upgrade process shouldn’t harm your data but it is strongly advised that you back up your data just in case the process is unsuccessful or you run into problems when upgrading.

 

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.

# ./migrate2rocky.sh -r

Removing dnf cache
Preparing to migrate CentOS Linux 8 to Rocky Linux 8.

Determining repository names for CentOS Linux 8.....

Found the following repositories which map from CentOS Linux 8 to Rocky Linux 8:
CentOS Linux 8  Rocky Linux 8
appstream       appstream
baseos          baseos
extras          extras

Getting system package names for CentOS Linux 8..........

Found the following system packages which map from CentOS Linux 8 to Rocky Linux 8:
CentOS Linux 8        Rocky Linux 8
centos-logos-ipa      rocky-logos-ipa
centos-backgrounds    rocky-backgrounds
centos-gpg-keys       rocky-gpg-keys
centos-logos          rocky-logos
centos-indexhtml      rocky-indexhtml
centos-linux-release  rocky-release
centos-logos-httpd    rocky-logos-httpd
centos-linux-repos    rocky-repos

Getting list of installed system packages.

We will replace the following CentOS Linux 8 packages with their Rocky Linux 8 equivalents
Packages to be Removed  Packages to be Installed
centos-gpg-keys         rocky-gpg-keys
centos-linux-release    rocky-release
centos-linux-repos      rocky-repos

Getting a list of enabled modules for the system repositories.

In addition to the above the following system packages will be removed:
centos-linux-release
centos-linux-release

Excluding modules:
libselinux-python:2.8

Found the following modules to re-enable at completion:
container-tools:rhel8
httpd:2.4
mariadb:10.3
perl-IO-Socket-SSL:2.066
perl-libwww-perl:6.34
python27:2.7
python36:3.6
ruby:2.5

Running dnf update before we attempt the migration.
....

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 now

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.4, check the OS-Release version;

# cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.4 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel fedora"
VERSION_ID="8.4"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8.4:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
[root@centos ~]#

The above output verifies that we are running on the latest version of Rocky Linux, which is 8.4.

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.4. I hope the steps are clear and you can easily follow them. Feel free to reach out in case you encounter any problems.

 

References

Transition from CentOS to Rocky

 

Related Searches: upgrade centos to rocky linux, migrate centos 7 to rocky linux, upgrade centos 7 to 8, centos 7 to 8 upgrade failed, upgrade centos 6 to 8

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

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 either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment