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.
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 update
Code 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.
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.rpm
Code language: Bash (bash)
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-rocky
Code language: Bash (bash)
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 preupgrade
Code 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.
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=True
Code 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 preupgrade
Code language: Bash (bash)
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 upgrade
Code 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 reboot
Code 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.
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.โ
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-release
Code language: Bash (bash)
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-release
Code 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-release
Code language: Bash (bash)
Refresh the package base:
sudo dnf update
Code 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.