Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.

Gallery

Contacts

411 University St, Seattle, USA

engitech@oceanthemes.net

+1 -800-456-478-23

Γενικά

Migrating from CentOS 7 to Alma Linux 8

As of June 30, 2024, CentOS 7 reached its end of life (EOL). That means it will no longer receive updates, bug fixes, critical security patches, or any new features. It is very important to migrate to a supported operating system to maintain the functionality and security of your systems. AlmaLinux is a reliable alternative to CentOS. It's a community-driven enterprise distribution that is binary compatible with Red Hat Enterprise Linux (RHEL). It's an environment similar to what CentOS users are used to as well as being free and open source.

Upgrading your CentOS 7 devices to AlmaLinux 8 will take a little planning.

  • Update the system to get the latest updates.

Step 1.

When you try to update your system, you get this error:

Cannot find a valid baseurl for repo: base/7/x86_64

or

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

  • Update the system to get the latest updates and reboot your machine. NOTE: Since the CentOS 7 repositories are now offline you will need to swap to the CentOS vault, or you can use AlmaLInux-CentOS 7 mirror:
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://el7.repo.almalinux.org/centos/CentOS-Base.repo sudo yum upgrade -y sudo reboot

    Step 2.

    • Next you need to install the elevate-release package with the project repo and GPG key:
    sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
    
    • Install leap packages and upgrade data for AlmaLinux:
    sudo yum install -y leapp-upgrade leapp-data-almalinux
    
    • Start a preupgrade check. In the meantime, the Leapp utility creates a special /var/log/leapp/leapp-report.txt file that contains possible problems and recommended solutions. No rpm packages will be installed at this phase.
    sudo leapp preupgrade
    
    • This summary report will help you get a picture of whether it is possible to continue the upgrade.

    TIP: In certain configurations, Leapp generates /var/log/leapp/answerfile with true/false questions. Leapp utility requires answers to all these questions in order to proceed with the upgrade.

    • The following fixes from the /var/log/leapp/leapp-report.txt file are the most popular for CentOS 7, but it's recommended to review the whole file
    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
    • If we have encrypted disks with LUKS, we will see that leap package does not support installation with luks disks via the actor inhibitwhenluks. The trick is to delete the actor inhibitwhenluks and try to run leap again. (IT-Hure) So we run:
    sudo rm -rf /usr/share/leapp-repository/repositories/system_upgrade/common/actors/inhibitwhenluks
    • Also for Alma you may need to allow non RedHat Kernel to be installed: remove abort in /usr/share/leapp-repository/repositories/system_upgrade/common/actors/kernel/checkinstalledkernels/libraries/checkinstalledkernels.py
    sed -e 's:raise StopActorExecutionError:#raise StopActorExecutionError:g' /usr/share/leapp-repository/repositories/system_upgrade/common/actors/kernel/checkinstalledkernels/libraries/checkinstalledkernels.py

    We delete the old answers file and run again the leap preupgrade command and check if there are errors to solve. When done we can now run the leap upgrade command

    • Start an upgrade. You'll be offered to reboot the system after this process is completed.
    sudo leapp upgrade
    sudo reboot
    • A new entry in GRUB called ELevate-Upgrade-Initramfs will appear. The system will be automatically booted into it. See how the update process goes in the console.
    • After reboot, login to the system and check how the upgrade went. Verify that the current OS is the one you need. Check logs and packages left from the previous OS version, consider removing or updating them manually.
    cat /etc/redhat-release
    cat /etc/os-release
    rpm -qa | grep el7 
    cat /var/log/leapp/leapp-report.txt
    cat /var/log/leapp/leapp-upgrade.log
    • Navigate to the /etc/ directory and use an editor of your choice to edit the yum.conf file. You need to remove everything from the exclude line especially that refers to elevate or leap or comment the line.

    An example of yum.conf file:

    [main] gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True best=True skip_if_unavailable=False exclude=python2-leapp,snactor,leapp-upgrade-el7toel8,leapp
    • We do the same in /etc/dnf/dnf.conf
    • Now you can remove/manually upgrade packages left from CentOS 7 without any conflicts.
    • Check packages left from CentOS 7:
    rpm -qa | grep el7
    • f you face difficulties while removing the packages, the following command might help you:
    sudo rpm -e --nodeps
    • You can also check for the packages left from the upgrade process and remove them:
    rpm -qa | grep elevate
    rpm -qa | grep leapp
    • Check if you have the /root/tmp_leapp_py3 directory created and if so delete it.
    sudo rm -fr /root/tmp_leapp_py3
    • Clean your machine.
    sudo dnf clean all
    • You may also have to remove old RSA/SHA1 GPG keys. List the keys:
    rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}t%{SUMMARY}n'
    • To remove them, use the rpm -e command:
    sudo rpm -e [keyname]

    Fully update your system

    sudo dnf makecache
    sudo dnf distro-sync
    sudo reboot

    Login in your new Alma Linux 8 system again!

    Enjoy!

     

    Author

    Secure Networks