Skip to content

Instantly share code, notes, and snippets.

@mikepage
Last active January 1, 2025 23:32
Show Gist options
  • Save mikepage/c96ebcac9591903041b59c6392e23095 to your computer and use it in GitHub Desktop.
Save mikepage/c96ebcac9591903041b59c6392e23095 to your computer and use it in GitHub Desktop.

Upgrade CentOS 7 to AlmaLinux 8

In 2020, Red Hat announced that CentOS 8 will no longer receive support after the end of 2021 and will be succeeded by CentOS Stream, see also our article 'What is CentOS Stream'. CentOS 7 will be supported longer until June 30, 2024.

You may want to upgrade to an alternative to CentOS before then, but reinstalling your VPS is not a desirable option. In this guide, we show you how to upgrade your VPS from CentOS 7 to AlmaLinux 8 (or OracleLinux or Rocky Linux).

The steps in this guide have been successfully tested on up-to-date installations of CentOS 7 and DirectAdmin 1.63.0 with CentOS 7.

Take a snapshot before you start the upgrade process so that you can fall back on it if you experience problems after upgrading to AlmaLinux.

Step 1

Connect to your VPS via the VPS console in your control panel or via SSH.

Step 2 - optional with private networks

If your VPS is included in a private network, a network adapter is set up for it. The associated configuration file prevents you from upgrading to AlmaLinux.

First check the name of your private network adapter:

ls /etc/sysconfig/network-scripts/ifcfg The private network adapter has a name such as ifcfg-eth0:1 or ifcfg-eth1. Rename the corresponding network adapter (change the file name of the private network adapter if necessary):

mv /etc/sysconfig/network-scripts/ifcfg-eth0:1 /etc/sysconfig/backup

Step 3

Update and restart your VPS:

yum-y update
reboot

Step 4

Then install the elevate-release and leapp packages and the necessary migration data.

leapp-data-almalinux contains the migration data. In fact, this indicates that it concerns a migration to almalinux. You can also choose oraclelinux or rockylinux here by replacing leapp-data-almalinux with leapp-data-oraclelinux or leapp-data-rocky.

yum -y install http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm
yum -y install leapp-upgrade leapp-data-almalinux

Step 5

Now run the pre-upgrade check.

leapp pre-upgrade
The first time you run it, you always get a message at the end that the upgrade cannot be performed because some 'inhibitors' are found. You can recognize this by the message:

========================================================= ===
                UPGRADE INHIBITED
========================================================= ===
Finding 'inhibitors' at this point is normal and necessary to generate, for example, an answer file (see next step) and to see any kernel mods that need to be removed.

Step 6

There are some 'inhibitors' that prevent the upgrade process from running yet. The first is the pam_pkcs11 module which is not available in RHEL-8. An answer file has been generated for this issue (/var/log/leapp/answerfile) asking if pam_pkcs11 may be removed.

Allow pam_pcks11 to be removed by editing the answer file or by running the following command:

leapp answer --section remove_pam_pkcs11_module_check.confirm=True

Step 7

SSH root access is required as part of the upgrade process. Not so much because you will be logged in as root via SSH, but because otherwise the upgrade process will adjust the SSH configuration to some default values, which means that logging in via SSH with a password is no longer possible.

Allow SSH root access with the following command:

sed -i -e "s/^PermitRootLogin no/PermitRootLogin yes/" /etc/ssh/sshd_config

Step 8

The last 'inhibitor' are unsupported kernel modules. This concerns the modules floppy and pata_acpi. You remove both with the commands:

modprobe -r floppy
modprobe -r pata_acpi

Step 9

Check that no other inhibitors are visible in the /var/log/leapp/leapp-report.txt file to be sure.

nano /var/log/leapp/leapp-report.txt
Issues in /var/log/leapp/leapp-report.txt that show as high without the addition (inhibitor) can be ignored.

Step 10

Run the leapp preupgrade command again:

leapp pre-upgrade

The pre-upgrade will now find no more inhibitors. At the end of the pre-upgrade check, you recognize that the process has been successful when you see the following output, among other things:

========================================================= ==========
                            REPORT
========================================================= ==========
A report has been generated at /var/log/leapp/leapp-report.json
A report has been generated at /var/log/leapp/leapp-report.txt
========================================================= ==========
                        END OF REPORT
========================================================= ==========

EPEL packages such as openssl can cause the upgrade process to hang, even though Leapp indicates that they are OK. Therefore, check in advance which EPEL packages you have installed and consider uninstalling them before the upgrade and reinstalling them after the upgrade. You check which EPEL packages you use with the command:

  yum list installed | grep epel

You can optionally remove packages with the command:

yum erase package name

Step 11

Now actually run the upgrade with the command:

leap upgrade

Step 12

Restart your VPS afterwards. The 'elevate-upgrade' process will now run to upgrade CentOS 7 to AlmaLinux 8. This will take some time (30-60 min). If you have been using SSH up to now, it is useful to take a look at the console in the TransIP control panel for this step to keep an eye on the progress.

reboot

Step 13

When the process is finished, you will recognize this by the following message:

leapp upgrade complete

Your login screen is not visible. Press 'Enter' to bring it up. You will then see a login prompt as in the screenshot above. Log in as root user.

Note: did you restart your VPS? Then your console is probably now being spammed with IPv6 errors. This is because the network configuration for IPv6 of CentOS 7 differs from that of RHEL-8. You can ignore these notifications for now, but they are annoying because they make it difficult to see what you are typing. Our advice if this happens to you: don't look at your console as much as possible while you go through these steps (preferably at your keyboard), or use SSH.

Step 14

Disable the permission to log in as root user via SSH and restart your SSH server:

sed -i -e "s/^PermitRootLogin yes/PermitRootLogin no/" /etc/ssh/sshd_config
systemctl restart sshd

Step 15

Correct your IPv6 configuration with the following commands (use 'paste to console' if you are using the console in the TransIP control panel):

echo IPV6_AUTOCONF=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6_DEFROUTE=yes >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo IPV6_FAILURE_FATAL=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
ifdown eth0 && ifup eth0

You will receive a notification that ifdown and ifup will be removed in the future. This is only a warning and does not cause any further problems. At the time of writing (November 2021), the network manager alternative does not always work either. If ifup and ifdown have been removed by the time you read this, you can try the network manager alternative as follows:

nmcli networking off && nmcli networking on

Step 16 - optional with private networks

If you are using a private network, now rename the network configuration file and restart your interface:

mv /etc/sysconfig/backup /etc/sysconfig/network-scripts/ifcfg-eth0:1
ifdown eth0 && ifup eth0

Step 17

Congratulations! Your CentOS 7 installation has now been completely converted to AlmaLinux 8. Check that the upgrade has been performed correctly with the following command and then restart your VPS to make sure that no problems have arisen during this process:

cat /etc/os-release
reboot

Step 18 - DirectAdmin

Did you use DirectAdmin in combination with CentOS 7? Rebuild software managed by CustomBuild again, otherwise some software may not work. You can do this easily with two commands:

cd /usr/local/directadmin/custombuild
./build all d

That brings us to the end of this guide to upgrading from CentOS 7 to AlmaLinux 8.

@jelmerjellema
Copy link

For me on Centos 7 (TransIp) it was not enough to just move the ifcfg-eth1 file out of the way. I had to rename both eth* devices using net link eth0 name public before this inhibitor was removed.

@chapmanjacobd
Copy link

On DigitalOcean the network renaming step looked like this:

sudoedit /etc/sysconfig/network-scripts/ifcfg-eth0  # rename DEVICE=eth0 to DEVICE=ens0
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-ens0
mv /etc/sysconfig/network-scripts/route-eth0 /etc/sysconfig/network-scripts/route-ens0
mv /etc/sysconfig/network-scripts/route6-eth0 /etc/sysconfig/network-scripts/route6-ens0
ifdown eth0; ip link set eth0 name ens0; ifup ens0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment