CentOS/Dirty RHEL7 to CentOS8

From Omnia
Revision as of 05:30, 3 August 2026 by Kenneth (talk | contribs) (Created page with "== Unsupported RHEL7 to CentOS8 Upgrade == <markdown> # RHEL 7.9 to CentOS 8.5.2111 Migration Runbook for VMs > **Important warning** > > This is an unsupported in-place conversion path. Use this only on VMs where you have a working snapshot, console access, and a recovery plan. A fresh install of AlmaLinux, Rocky Linux, RHEL, or another supported EL distribution is generally safer for production systems. ## Scope This runbook captures the field-tested steps used to...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Unsupported RHEL7 to CentOS8 Upgrade

<markdown>

  1. RHEL 7.9 to CentOS 8.5.2111 Migration Runbook for VMs

> **Important warning** > > This is an unsupported in-place conversion path. Use this only on VMs where you have a working snapshot, console access, and a recovery plan. A fresh install of AlmaLinux, Rocky Linux, RHEL, or another supported EL distribution is generally safer for production systems.

    1. Scope

This runbook captures the field-tested steps used to convert a VM from:

```text Red Hat Enterprise Linux Server release 7.9 (Maipo) ```

to:

```text CentOS Linux 8.5.2111 ```

The key breakthrough was getting the VM booted on the EL8 kernel first, then completing the userspace conversion with `dnf distro-sync`.

---

    1. 1. Snapshot and capture the current state

Take a VM snapshot before making changes.

Capture package and repo state:

```bash cat /etc/redhat-release rpm -qa | sort > /root/packages.before-rhel7-to-centos8.txt cp -a /etc/yum.repos.d /root/yum.repos.d.before-rhel7-to-centos8 ```

Install DNF if it is not already present:

```bash yum install -y dnf ```

---

    1. 2. Remove the RHEL release package

The CentOS release package conflicts with `redhat-release-server` because both own files such as:

```text /etc/os-release /etc/redhat-release /etc/system-release /etc/system-release-cpe /etc/rpm/macros.dist ```

Remove the RHEL release package:

```bash rpm -e --nodeps redhat-release-server ```

If the system already has no `/etc/redhat-release`, verify the release package state:

```bash rpm -q redhat-release-server ```

---

    1. 3. Install CentOS 8.5.2111 release packages

Install the CentOS release, repo, and GPG key RPMs from the CentOS vault:

```bash dnf install -y \

   http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-repos-8-3.el8.noarch.rpm \
   http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-linux-release-8.5-1.2111.el8.noarch.rpm \
   http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-3.el8.noarch.rpm

```

Verify:

```bash rpm -q centos-linux-release rpm -q centos-linux-repos rpm -q centos-gpg-keys ```

Expected examples:

```text centos-linux-release-8.5-1.2111.el8.noarch centos-linux-repos-8-3.el8.noarch centos-gpg-keys-8-3.el8.noarch ```

---

    1. 4. Replace repo configuration with a clean CentOS vault repo

The repo files installed by `centos-linux-repos` may point at dead mirrorlist or duplicate repo definitions. The cleanest approach was to remove existing repo files and create a single vault repo file.

Back up and remove current repo files:

```bash mkdir -p /root/yum.repos.d.after-centos-release-install cp -a /etc/yum.repos.d/*.repo /root/yum.repos.d.after-centos-release-install/ 2>/dev/null || true rm -f /etc/yum.repos.d/*.repo ```

Create `/etc/yum.repos.d/CentOS-Linux-Vault-8.5.2111.repo`:

```bash cat > /etc/yum.repos.d/CentOS-Linux-Vault-8.5.2111.repo <<'EOF' [baseos] name=CentOS Linux 8.5.2111 - BaseOS baseurl=http://vault.centos.org/8.5.2111/BaseOS/x86_64/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[appstream] name=CentOS Linux 8.5.2111 - AppStream baseurl=http://vault.centos.org/8.5.2111/AppStream/x86_64/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[extras] name=CentOS Linux 8.5.2111 - Extras baseurl=http://vault.centos.org/8.5.2111/extras/x86_64/os/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[powertools] name=CentOS Linux 8.5.2111 - PowerTools baseurl=http://vault.centos.org/8.5.2111/PowerTools/x86_64/os/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial EOF ```

Clean and verify repo metadata:

```bash dnf clean all rm -rf /var/cache/dnf/* dnf repolist ```

Expected healthy repo result:

```text appstream CentOS Linux 8.5.2111 - AppStream baseos CentOS Linux 8.5.2111 - BaseOS extras CentOS Linux 8.5.2111 - Extras ```

If DNF reports duplicate repos such as `baseos is listed more than once`, remove the duplicate `.repo` files and keep only the vault repo above.

---

    1. 5. Install EL8 kernel packages

Install the EL8 kernel packages:

```bash dnf --releasever=8 install -y kernel-core kernel-modules ```

Verify:

```bash rpm -qa 'kernel*' | sort ```

You want to see:

```text kernel-core-4.18.0-348.7.1.el8_5.x86_64 kernel-modules-4.18.0-348.7.1.el8_5.x86_64 ```

At this point, the system may still be booted on the EL7 kernel:

```bash uname -r ```

Example:

```text 3.10.0-1160.119.1.el7.x86_64 ```

---

    1. 6. Repair incomplete EL8 kernel installation if needed

In the observed migration, the RPM database showed the EL8 kernel installed, but `/boot/vmlinuz-4.18...` was initially missing and GRUB had no EL8 entry.

Check:

```bash ls -l /boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 rpm -ql kernel-core-4.18.0-348.7.1.el8_5.x86_64 | grep vmlinuz ```

If the file is missing, reinstall the kernel packages:

```bash dnf --releasever=8 reinstall -y \

   kernel-core-4.18.0-348.7.1.el8_5 \
   kernel-modules-4.18.0-348.7.1.el8_5

```

If you see this during reinstall:

```text Symvers dump file /boot/symvers-4.18.0-348.7.1.el8_5.x86_64.gz not found warning: %posttrans(kernel-core...) scriptlet failed ```

continue with the manual repair steps below.

---

    1. 7. Generate EL8 module dependencies

If `dracut` reports:

```text /lib/modules/4.18.0-348.7.1.el8_5.x86_64/modules.dep is missing. Did you run depmod? ```

run:

```bash depmod 4.18.0-348.7.1.el8_5.x86_64 ```

Verify:

```bash ls -l /lib/modules/4.18.0-348.7.1.el8_5.x86_64/modules.dep ```

---

    1. 8. Build the EL8 initramfs

```bash dracut -f \

   /boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img \
   4.18.0-348.7.1.el8_5.x86_64

```

Verify:

```bash ls -l /boot/initramfs-4.18.0-348.7.1.el8_5.x86_64.img ```

---

    1. 9. Add the EL8 kernel to GRUB

```bash kernel-install add \

   4.18.0-348.7.1.el8_5.x86_64 \
   /boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64

```

Verify GRUB entries:

```bash grubby --info=ALL | egrep '^(index|kernel|title)' ```

Expected EL8 entry:

```text kernel=/boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 title=CentOS Linux (4.18.0-348.7.1.el8_5.x86_64) 8 ```

Set it as default:

```bash grubby --set-default /boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 ```

Verify:

```bash grubby --default-kernel ```

Expected:

```text /boot/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 ```

---

    1. 10. Reboot into the EL8 kernel

Once the EL8 kernel, initramfs, and GRUB entry are present:

```bash sync reboot ```

After boot:

```bash uname -r cat /etc/os-release ```

Expected:

```text 4.18.0-348.7.1.el8_5.x86_64 ```

and CentOS Linux 8 identity in `/etc/os-release`.

This was the major breakthrough. After booting the EL8 kernel, the previous protected-kernel error became easier to work around.

---

    1. 11. Remove known blockers before userspace sync

Some EL7 packages blocked the EL8 transaction through dependency pins or file ownership conflicts.

Remove known blockers as needed:

```bash rpm -e --nodeps systemd-sysv || true rpm -e --nodeps dracut-network || true rpm -e --nodeps python3-setuptools || true rpm -e --nodeps sysvinit-tools || true rpm -e --nodeps python-sssdconfig || true rpm -e --nodeps python-syspurpose || true ```

Optional cleanup of RHEL subscription/support packages:

```bash rpm -e --nodeps \

   subscription-manager-rhsm \
   subscription-manager-rhsm-certificates \
   redhat-support-lib-python \
   redhat-support-tool \
   insights-client \
   python-syspurpose 2>/dev/null || true

```

Expected recurring blockers encountered:

```text systemd-sysv python3-setuptools redhat-rpm-config annobin vim-minimal yum sysvinit-tools python-sssdconfig python-syspurpose dracut-network ```

---

    1. 12. Run the main userspace distro-sync

Run the conversion sync with known build-tool blockers excluded initially:

```bash dnf --releasever=8 \

   --allowerasing \
   --setopt=deltarpm=false \
   --exclude=annobin \
   --exclude=redhat-rpm-config \
   --exclude=gcc \
   --exclude=gcc-c++ \
   --exclude=rpm-build \
   distro-sync

```

If it fails with file conflicts, use the pattern below.

---

    1. 13. Resolve file ownership conflicts

A common error pattern is:

```text file /path/from install of EL8-package conflicts with file from package EL7-package ```

Resolve by identifying and removing the old EL7 package:

```bash rpm -qf /path/from/error rpm -e --nodeps old-el7-package ```

Then rerun:

```bash dnf --releasever=8 \

   --allowerasing \
   --setopt=deltarpm=false \
   --exclude=annobin \
   --exclude=redhat-rpm-config \
   --exclude=gcc \
   --exclude=gcc-c++ \
   --exclude=rpm-build \
   distro-sync

```

Repeat until the transaction succeeds.

Examples encountered:

      1. `sysvinit-tools`

Conflicted with EL8 `procps-ng` and `util-linux` for:

```text /usr/sbin/pidof /usr/bin/last /usr/bin/mesg /usr/bin/wall ```

Fix:

```bash rpm -e --nodeps sysvinit-tools ```

      1. `python-sssdconfig`

Conflicted with EL8 `python3-sssdconfig`.

Fix:

```bash rpm -e --nodeps python-sssdconfig ```

      1. `python-syspurpose`

Conflicted with EL8 `python3-syspurpose`.

Fix:

```bash rpm -e --nodeps python-syspurpose ```

      1. `dracut-network`

EL7 `dracut-network` required the exact EL7 dracut version.

Fix:

```bash rpm -e --nodeps dracut-network ```

---

    1. 14. Validate core userspace after successful sync

After a successful userspace sync, check:

```bash uname -r cat /etc/os-release rpm -q rpm rpm-libs rpm-build-libs rpm -q dnf python3-dnf rpm -q systemd dracut kmod rpm -q glibc bash openssl openssh-server ```

Expected direction:

```text rpm-4.14.x.el8 systemd-239.x.el8 dracut-049.x.el8 dnf-4.7.x.el8 glibc-2.28.x.el8 ```

Check remaining EL7 packages:

```bash rpm -qa | grep el7 | sort > /root/packages.remaining-el7.txt wc -l /root/packages.remaining-el7.txt ```

Continue cleaning up remaining EL7 packages case by case.

---

    1. 15. Reinstall build tooling after RPM stack becomes EL8

Only after the RPM/DNF stack is converted to EL8, reinstall build tools:

```bash dnf install -y \

   gcc \
   gcc-c++ \
   make \
   rpm-build \
   redhat-rpm-config \
   annobin

```

This avoids early errors such as:

```text rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin ```

---

    1. 16. Final checks

```bash uname -r cat /etc/os-release dnf repolist systemctl --failed rpm -qa | grep el7 | sort ```

Check SSH:

```bash systemctl status sshd sshd -t ```

Check SELinux if SSH or login behavior changes:

```bash getenforce ausearch -m avc -ts recent ```

---

    1. Key Lessons Learned

1. **Fix repos first.** Duplicate or mirrorlist-based CentOS 8 repo files caused DNF to report `0 B` metadata and misleading `Nothing to do` results. 2. **Boot the EL8 kernel before completing userspace conversion.** The protected-kernel failure was caused by DNF trying to remove the currently running EL7 kernel. 3. **Manually repair the EL8 kernel install if posttrans fails.** `depmod`, `dracut`, and `kernel-install add` were required to make the EL8 kernel bootable. 4. **Expect repeated EL7 file ownership conflicts.** Remove the old EL7 owner with `rpm -e --nodeps`, then rerun `distro-sync`. 5. **Delay build tooling until the RPM stack is EL8.** Packages like `annobin` and `redhat-rpm-config` use rich dependencies that the EL7 RPM stack cannot process cleanly. 6. **This is a migration bridge, not a final ideal state.** CentOS 8.5.2111 is end-of-life. Once the system is stable, consider moving to a supported EL8 or EL9 platform such as AlmaLinux, Rocky Linux, or RHEL.

</markdown>