Upgrade Centos7 to Rocky8 Use Leapp
Prepare
BACKUP EVERYTHING BEFORE DOING THIS
- Stop SELinux and disable it (RedHat)
sudo setenforce 0
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- Update Cent 7 deps
sudo yum update -y
sudo reboot
- Install elevate-release from alma
sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
I use Rocky so I need choose leapp-data-rocky
sudo yum install -y leapp-upgrade leapp-data-rocky
Check before real update
sudo leapp preupgrade
Don’t know what shit but do it
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
Upgrade
Do real upgrade
sudo leapp upgrade
For myself centos7 cmake3
and python3-pip
conflicted with CentOS8, so remove it before
sudo yum remove cmake3
sudo yum remove python3-pip
After leapp
upgrade
Warning: don’t reboot directly, need rebuild grub at first
depend on various dist, it located in /boot/grub/grub.cfg
or/boot/grub2/grub.cfg
grub2-mkconfig -o /path/to/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.114.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.114.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.71.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.71.1.el7.x86_64.img
done
When you see ELevate-Upgrade-Initramfs
in the grub list then you can reboot, otherwise you will lost your system boot
In ELevate-Upgrade-Initramfs
Waiting ELevate-Upgrade-Initramfs
finish running
After Upgrade-Initramfs running
grub always failed that CentOS7 not compatible fine with CentOS8 so in my VM, I also need manually boot at first
- Check which boot file you can use
grub> ls (hd0)/
bin/ boot/ dev/ ....
grub> cat (hd0)/etc/redhat-releases
Fedora release 27 (Twenty Seven)
grub> ls (hd0)/boot/
.... initramfs-4.14-11-300.fc27.x86_64.img .... vmlinuz-4.14.11-300.fc27.x86_64 ...
- Set and boot manually (replace
/dev/sda
in your situation)
grub> set root=(hd0)
grub> linux /boot/vmlinuz-4.18.0-513.24.1.el8_9.x86_64 root=/dev/sda
grub> initrd /boot/initramfs-4.18.0-513.24.1.el8_9.x86_64.img
grub> boot
After Upgrade
Re-install grub2
Manually boot into Rocky and re-install grub2 (force)
[root@xxx ~]$ grub2-install -force /dev/sda
Rebuild grub2 config
[root@xxx ~]$ grub2-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
done
If you cannot see any boot file in list, please check /etc/default/grub
## /etc/default/grub
GRUB_ENABLE_BLSCFG=true # set to false
GRUB_TIMEOUT=30
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
.....
then rebuild grub2 config again
[root@xxx ~]$ grub2-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.18.0-513.24.1.el8_9.x86_64
Found initrd image: /boot/initramfs-4.18.0-513.24.1.el8_9.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.114.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.114.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.71.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.71.1.el7.x86_64.img
done