Migrating from CentOS 7 to Rocky Linux 8: A Step-by-Step Guide

Migrate from CentOS 7 to Rocky Linux 8 seamlessly with our proven and tested guide. Ensure a smooth transition with no data loss.

On June 30, 2024, CentOS 7 will reach End of Life (EOL). This means no more updates, which essentially sidelines it from the server lineup.

With that said, itโ€™s not the best idea to wait until the eleventh hour to make a move. Being proactive is the way to go. So, if your Linux server is still rocking CentOS 7, thereโ€™s no need to fret. Youโ€™ve come to the right place.

Since youโ€™re here, by all appearances, youโ€™re leaning toward Rocky Linux, so welcome to the family! Weโ€™re here to guide you smoothly through the transition from CentOS 7 to Rocky 8. As you will see, with the right instructions, this change is much simpler than you might think.

However, before we get to the action, there are a few key points we need to clear up.

CentOS 7 to Rocky Linux Upgrade Path

Iโ€™m sure one of the burning questions you might have is, โ€œWhy should I upgrade to Rocky 8 first instead of jumping directly to Rocky 9?โ€ Hereโ€™s a crucial bit of info to keep in mind: itโ€™s not possible to migrate from CentOS 7 to Rocky 9 directly.

So, if you aim to transition to Rocky 9, the path involves initially migrating your current CentOS 7 system to Rocky 8. Once thatโ€™s done, you can then move on to upgrade from Rocky 8 to Rocky 9. This two-step process ensures a smooth transition and compatibility across versions.

CentOS 7 to Rocky Linux upgrade path.
CentOS 7 to Rocky Linux upgrade path.

Additionally, no need to worry about transitioning from Rocky 8 to 9; weโ€™ve got your back! While itโ€™s true that Rocky doesnโ€™t officially support this upgrade path and usually recommends starting fresh, weโ€™ve paved the way for those who wish to proceed.

Our detailed guide, โ€œHow to Upgrade from Rocky Linux 8 to 9,โ€ is here to help. So, after youโ€™re through with your current migration, peek into our guide for the steps to seamlessly migrate to Rocky 9 if thatโ€™s the goal. 

What Is In-Place Upgrade?

As you noticed in the diagram above, it explicitly states that we will perform an in-place upgrade. Hereโ€™s what that means.

An in-place upgrade refers to updating the current operating system to a newer version without removing the existing one and manually reinstalling or reconfiguring the system and applications.

This means youโ€™re essentially upgrading the OS while itโ€™s running to retain your files, settings, applications, and custom configurations intact.

In light of this, the in-place upgrade process involves:

  • Replacing old packages with newer versions.
  • Resolving dependencies.
  • Making necessary adjustments to the system configuration to ensure compatibility with the new version.

Okay, everything is all set now, so itโ€™s time to act. Letโ€™s help you switch your current CentOS 7 server to Rocky 8!

Step 1: Take System Backup

It is highly recommended that you back up your essential files and configurations. We recommend making a full system backup so that you can restore your system with all the vital data to its previous state if something goes wrong.

For this purpose, we recommend using specialized software like the ones mentioned here to take a complete snapshot of the partitions on which CentOS 7 is installed.

In addition, you can always use a command like the one shown below, which will archive all of the more critical directories and their contents in a tar.gz archive.

sudo tar czf /centos7.tar.gz \
     --exclude=/centos7.tar.gz \
     --exclude=/dev \
     --exclude=/mnt \
     --exclude=/proc \
     --exclude=/sys \
     --exclude=/tmp \
     --exclude=/media \
     --exclude=/lost+found \
     /Code language: Bash (bash)

Feel free to add more โ€œโ€“exclude=โ€ parameters if needed. Finally, the command creates a backup of all files in โ€œcentos7.tar.gzโ€ located on the root partition (/), which you should ideally transfer to another computer or drive, for example, using the SCP command.

Step 2: Update All Software

Ensure your current CentOS 7 system is fully upgraded and has no packages waiting to be updated.

sudo yum updateCode language: Bash (bash)

If any updates are available, install them and, if necessary, reboot the system. Below is our current fully updated CentOS 7 server before we migrate to Rocky 8.

CentOS Linux 7.9.2009

As you can see, the system runs CentOS 7.9, the latest CentOS version in the 7.x branch.

Step 3: Migrate CentOS 7 to Rocky Linux 8

Letโ€™s say a few words about the tool that will help us with the migration, called ELevate. Designed by AlmaLinux, it supports migrations between major versions of Red Hat Enterprise Linux (RHEL) derivatives, allowing users to migrate from CentOS 7.x to 8.x versions of the RHEL derivative of their choice or upgrade from 8.x to 9.x within the same derivative.

The good part is that ELevate is developed with the entire RHEL-based ecosystem in mind, not just Alma, and supports migrating to and from other distributions. In our case, weโ€™ll be using it to migrate from CentOS 7 to Rocky 8. For more information, visit the projectโ€™s page.

Step 3.1: Install ELevate

The first step in the upgrade process is installing the โ€œelevate-releaseโ€ package on your current CentOS 7 system.

sudo yum install http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpmCode language: Bash (bash)
Install ELevate

Step 3.2: Install Leapp and Migration Data

The migration process is based on a combination of Red Hatโ€™s Leapp, a tool designed to facilitate in-place upgrades of RHEL systems from one major version to another, and a community-created library containing the migration metadata set. So, letโ€™s install them:

sudo yum install leapp-upgrade leapp-data-rockyCode language: Bash (bash)
Install Leapp and Migration Data

When you run the above command, it will install more than 30 extra packages, mostly Python-related dependencies. This is completely expected. Also, youโ€™ll see a prompt asking you to accept the GPG key for Almaโ€™s ELevate repository. Just go ahead and accept it.

Step 3.3: Start Pre-Upgrade Checks

The next step is to start a pre-upgrade check. The command below verifies server compatibility without making any actual changes and creates a “/var/log/leapp/leapp-report.txt” file that contains possible problems and recommended solutions:

sudo leapp preupgradeCode language: Bash (bash)

Most likely, some of the checks will fail, but there is no room for worry! Thatโ€™s normal because some tweaks are required in advance.

Pre-upgrade checks

According to the official documentation, the three commands below solve the issue. Just run them one after the other:

sudo rmmod pata_acpi
echo PermitRootLogin yes | sudo tee -a /etc/ssh/sshd_config
sudo leapp answer --section remove_pam_pkcs11_module_check.confirm=TrueCode language: Bash (bash)

Rerun the pre-upgrade check, and youโ€™ll see a green report confirming everything is in order. This means youโ€™re all set to proceed safely with the upgrade.

sudo leapp preupgradeCode language: Bash (bash)
Pre-upgrade checks

Step 3.4: Start the Actual Migration from CentOS 7 to Rocky 8

Run the following command to migrate your CentOS 7 system to Rocky Linux 8.

sudo leapp upgradeCode language: Bash (bash)

Please be aware that upgrading can occasionally lead to errors if you are using packages from external repositories, such as EPEL. A common example is encountering an issue with the โ€œopenssl11-libsโ€ package from the EPEL repo.

To fix it, uninstall the package by executingย yum remove <package_name>. Afterward, rerun theย sudo leap upgradeย command, which should proceed without issues.

Nowโ€™s the perfect time to grab a coffee and settle in – it will take a little while. Once the migration is completed, youโ€™ll be offered to reboot the system. Okay, the moment of truth!

sudo rebootCode language: Bash (bash)

After restart, youโ€™ll notice a new option called โ€œELevate-Upgrade-Initramfsโ€ pop up in the GRUB menu. Your computer will pick it up automatically and start on its own in just a few moments. This part calls for a bit of your patience again.

It will be busy working behind the scenes, installing packages, and getting them in order. Just hang tight and give it the time it needs to finish up all its tasks. Itโ€™s like baking a cake โ€“ waiting is hard, but the result is worth it.

GRUB menu

Since the package upgrades involve a lot of background activity, the process might take a while. Please be patient if you cannot access the terminal to track these changes. Depending on your hardwareโ€™s capabilities and the number ofย packagesย being updated, it could take anywhere from a few minutes to half an hour.

After everythingโ€™s wrapped up, your computer will smoothly restart. And guess what? Your screen will proudly show off the GRUB boot options for Rocky 8, sporting the cool name โ€œGreen Obsidian.โ€

GRUB menu

Congratulations! Just like that, you’ve successfully transitioned your system from CentOS 7 to Rocky Linux 8. A big congrats from me as well!

Step 4: Check the OS Version (Optional)

To ensure everythingโ€™s gone according to plan, why not take a quick peek at the OS version? Itโ€™s a great way to double-check and feel good about the update.

cat /etc/redhat-releaseCode language: Bash (bash)
Successful migration from CentOS 7 to Rocky Linux 8

Post-Installation Steps

We recommend starting by removing the EPEL repository if youโ€™re using it. It still targets the older CentOS 7 and could lead to errors due to compatibility issues when you try to upgrade your system or install new packages. To remove it, execute:

sudo dnf remove epel-releaseCode language: Bash (bash)

Then, you can add it again. The installer will recognize that your system is RHEL 8 compatible and will install the appropriate EPEL 8 repository.

sudo dnf install epel-releaseCode language: Bash (bash)

Refresh the package base:

sudo dnf updateCode language: Bash (bash)

Remove all CentOS 7-related packages. To find them, run the command below:

sudo rpm -aq | grep el7

Then open the โ€œ/etc/yum.confโ€ file and comment out the โ€œexcludeโ€ line shown below.

sudo nano /etc/yum.conf

Finally, to remove them, list them individually as arguments to theย dnf removeย command. In our case, it looks like this:

For a more in-depth introduction to the DNF command, we highly recommend consulting our article on the subject, โ€œDNF Command-Line Package Manager in Linux: A Complete Guide.โ€

Bottom Line

With our meticulously crafted step-by-step guide in hand, migrating from CentOS 7 to Rocky Linux 8 not only sounds like a breeze but actually is one.

Moreover, ifย youโ€™re looking for a different upgrade path to anotherย enterprise Linux distro, weโ€™re here to help. Check out our detailed guide on migrating from CentOS 7 toย AlmaLinux 8ย orย Oracle Linux 8.

Lastly, but definitely not least, thank you for your trust in us โ€“ it truly means the world! Weโ€™d love to hear your feedback or thoughts, so please donโ€™t hesitate to drop them in the comment box below.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%