How to migrate from CentOS 8 to RockyLinux 8.4

How to migrate from CentOS 8 to RockyLinux 8.4

The end of 2021 is approaching, which also means that the EOL (end of life cycle) of CentOS 8 is also approaching. So there is no more updates and support for CentOS 8 Linux, which is a huge disadvantage for everyone who uses CentOS as the main operating system in development and production environments. Instead, CentOS 8 has a new Linux distribution alternative, one of which is called “Rocky Linux“.

If you are a CentOS 8 user and want to migrate to Rocky Linux, there is no need to rebuild and reinstall your server/server. Because the Rocky Linux project provides a convenient migration tool for anyone who wants to migrate from CentOS 8 to Rocky Linux. This tool is a lifesaver for anyone who wants to migrate their development or production environment to Rocky Linux.

In this guide, you will learn how to migrate from CentOS 8 to Rocky Linux 8.4 using the migration tool provided by the Rocky Linux project.

Note before migration: Back up all application data on your server, take image snapshots of your CentOS 8 server to prevent data loss, and move the snapshots to a safe place.

prerequisites

  • A root user or user sudo privilege. The Rocky Linux migration script must be run as the root user.

Below is the screen of our CentOS 8 server before migrating to Rocky Linux.

Run the following command to check your CentOS system.

hostnamectl

You will get output similar to the screenshot at the top.

Upgrade all packages

First, you need to upgrade all the software packages on the CentOS 8 system, and then restart the server server.

1. Execute the following command to upgrade all packages to the latest version.

sudo dnf upgrade

Now enter “Yes“Confirm the package upgrade and wait, it will take time depending on your internet connection.

Upgrade all CentOS packages

2. After that, use the following command to restart the server to apply all changes to the system.

sudo reboot

After the server starts, log in to your server again, and then you can continue to the next stage.

Install Git

1. Execute the following command to install git on your system.

sudo dnf install git

type “you” To confirm the installation.

Install Git on CentOS

Now enter the next stage to continue.

Download Rocky tools

1. Clone the repository”Rock tools“Use the following git command to go to your root home directory.

git clone https://github.com/rocky-linux/rocky-tools.git

Inside”Rock tools“Under the directory you will see two tools,”migrate2rocky“The directory contains Rock Linux migration tools,”Mirror“The directory contains tools to keep Rocky Linux’s public and private mirrors in sync.

2. Change the working directory to “~/rocky-tools/migrate2rocky“And run”ls“The order is as follows.

cd rocky-tools/migrate2rocky; ls -lah

Now you will see bash Rocky Linux migration script”migrate2rocky.sh”.

Download Rocky Linux migration script

3. Next, make the script executable by changing the permissions of the file using the following chmod command.

chmod +x migrate2rocky.sh

4. Now execute the script”migrate2rocky.sh“As shown below to display help and all available options.

./migrate2rocky.sh -h

You will get output similar to the following, and you are ready to migrate your CentOS 8 system to Rocky Linux.

Usage: migrate2rocky.sh [OPTIONS]Options:-h Display this help-r Convert to rocky-V Verify switch   !! USE WITH CAUTION !!

Make Rocky Linux migration script executable and script help

Migrate CentOS 8 to Rocky Linux

1. Execute the following script to start the migration from CentOS 8 to Rocky Linux.

./migrate2rocky.sh -r

2. First, the script checks all the main repositories of CentOS 8 (AppStream, BaseOS and Extras) and remaps to Rocky Linux 8.

Removing dnf cachePreparing 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 8appstream       appstreambaseos          baseosextras          extras

Change the main repository from CentOS to Rocky Linux

3. After that, the script will replace all the packages related to CentOS with the new packages of Rocky Linux. In addition, it will remove unnecessary packages and install new additional packages.

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 8centos-logos-ipa      rocky-logos-ipacentos-backgrounds    rocky-backgroundscentos-gpg-keys       rocky-gpg-keyscentos-logos          rocky-logoscentos-indexhtml      rocky-indexhtmlcentos-linux-release  rocky-releasecentos-logos-httpd    rocky-logos-httpdcentos-linux-repos    rocky-reposGetting list of installed system packages.We will replace the following CentOS Linux 8 packages with their Rocky Linux 8 equivalentsPackages to be Removed  Packages to be Installedcentos-gpg-keys         rocky-gpg-keyscentos-linux-release    rocky-releasecentos-linux-repos      rocky-reposGetting a list of enabled modules for the system repositories.In addition to the above the following system packages will be removed:centos-linux-releasecentos-linux-releaseExcluding modules:libselinux-python:2.8Found the following modules to re-enable at completion:perl:5.26perl-IO-Socket-SSL:2.066perl-libwww-perl:6.34

Replace all packages with Rocky Linux package version

It will take some time to install the package during the migration process, so please make sure you have a good internet connection.

4. After the migration process is successful, you will get a similar output as shown below.

...Complete!Done, please reboot your system.

5. Next, execute the following command to ensure that all installed packages match the latest version available in any enabled repositories on the system.

sudo dnf distro-sync -y

6. After that, use the following command to restart the system to apply all changes to the system.

sudo reboot

Rocky Linux migration completed

7. Now during the boot process, you will see a grub window with Rocky Linux in the top menu.

Rocky Linux Grub after migration

choose”Rocky Linux (4xxxx) 8.4 (green obsidian)“then press”Enter“Boot to the new system.

Verify migration

1. Log in to the new system and execute the following command to verify the migration result.

hostnamectl

After a successful migration, you will see similar output as shown below.

   Static hostname: server1         Icon name: computer-vm           Chassis: vm        Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx           Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    Virtualization: oracle  Operating System: Rocky Linux 8.4 (Green Obsidian)       CPE OS Name: cpe:/o:rocky:rocky:8.4:GA            Kernel: Linux 4.18.0-305.10.2.el8_4.x86_64      Architecture: x86-64

Successfully migrated from CentOS 8 to Rocky Linux 8.4

2. In addition, you can display os-release on the system.

cat /etc/os-release

You will get the following output.

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"

in conclusion

Congratulations! You have successfully migrated CentOS 8 to Rocky Linux 8.4. The migration process went smoothly without any errors, and the system was up and running as Rocky Linux. Now you are ready to start all services and applications.