rancherOSのcentos consoleをalmalinux 9にupgradeするためのメモ

* 参考記事

https://engineering.mobalab.net/2021/07/01/centos-7-to-8/

https://www.cyberciti.biz/howto/how-to-migrate-from-centos-8-to-almalinux-conversion/

https://www.centlinux.com/2022/07/upgrade-your-servers-from-rocky-linux-8-to-9.html

* 本稿で作成したスクリプトのリポジトリ

https://github.com/Yougain/rancher_os_efi

* (1) CentOS 7　→　CentOS 8
　# ros console switch centos -f
　# rpm -qa > original_package_list (元のパッケージリストを保存しておく)
　# yum -y install epel-release yum-utils
　# yum -y install dnf　# yum clean all
　# dnf -y remove yum yum-metadata-parser
　# rm -Rf /etc/yum /var/cache/yum
　# dnf -y upgrade
　# dnf -y install https://vault.centos.org/8.5.2111/BaseOS/x86_64/os/Packages/centos-{linux-release-8.5-1.2111,linux-repos-8-3,gpg-keys-8-3}.el8.noarch.rpm
　# sed -i -r 's/\bmirrorlist\=/#mirrorlist=/' /etc/yum.repos.d/CentOS-Linux-\*.repo
　# sed -i -r "s/#baseurl=http:\\/\\/mirror/baseurl=http:\\/\\/vault/" /etc/yum.repos.d/CentOS-Linux-\*.repo
　# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
* (2) CentOS 8 → Almalinux 8
　# wget https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
　# vi almalinux-deploy.sh
　これを以下のように修正する。
```
diff -Nc almalinux-deploy.sh almalinux-deploy.sh
*** almalinux-deploy.sh 2023-01-18 13:28:28.096019365 +0000
--- almalinux-deploy.sh 2023-01-18 13:31:35.712659621 +0000
***************
*** 1014,1021 ****
      local panel_version
      assert_run_as_root
      arch="$(get_system_arch)"
!     os_type="$(get_os_release_var 'ID')"
!     os_version="$(get_os_version "${os_type}")"
      #os_version="$(get_os_release_var 'VERSION_ID')"
      #os_version="${os_version:0:1}"
      assert_supported_system "${os_type}" "${os_version}" "${arch}"
--- 1014,1021 ----
      local panel_version
      assert_run_as_root
      arch="$(get_system_arch)"
!     os_type="centos"
!     os_version="8"
      #os_version="$(get_os_release_var 'VERSION_ID')"
      #os_version="${os_version:0:1}"
      assert_supported_system "${os_type}" "${os_version}" "${arch}"
***************
*** 1070,1082 ****
      restore_alternatives
      restore_issue
      # don't do this steps if we inside the lxc container
!     if [ $is_container -eq 0 ]; then
!         install_kernel
!         grub_update
!         reinstall_secure_boot_packages
!         add_efi_boot_record
!     fi
!     check_custom_kernel
      save_status_of_stage "completed"
      printf '\n\033[0;32mMigration to AlmaLinux is completed\033[0m\n'
  }
--- 1070,1082 ----
      restore_alternatives
      restore_issue
      # don't do this steps if we inside the lxc container
!     #if [ $is_container -eq 0 ]; then
!         #install_kernel
!         #grub_update
!         #reinstall_secure_boot_packages
!         #add_efi_boot_record
!     #fi
!     #check_custom_kernel
      save_status_of_stage "completed"
      printf '\n\033[0;32mMigration to AlmaLinux is completed\033[0m\n'
  }
```
　# chmod -v +x almalinux-deploy.sh
　# ./almalinux-deploy.sh
* (3) Almalinux 8 → Almalinux 9
　# dnf install -y https://repo.almalinux.org/almalinux/9.1/BaseOS/x86_64/os/Packages/almalinux-{gpg-keys,release,repos}-9.1-1.9.el9.x86_64.rpm
　# dnf install -y epel-release-9
　# dnf -y --releasever=9 --allowerasing --setopt=deltarpm=false distro-sync --skip-broken　# rpm --rebuilddb
　# cp /var/lib/rpmrebuilddb.xxxx/* /var/lib/rpm
　# dnf -y module reset perl perl-IO-Socket-SSL perl-libwww-perl
　(以下、元のconsole imageに入っていないパッケージを削除)
　# rpm -e compat-openssl10 dbus-daemon dbus-tools dnf-plugins-core ed elfutils-debuginfod-client file freetype fuse-libs gawk-all-langpacks gettext gettext-libs glibc-gconv-extra gnupg2-smime graphite2 grub2-common grub2-tools grub2-tools-efi grub2-tools-extra grub2-tools-minimal grubby harfbuzz hwdata kbd-legacy libcroco libmetalink libnsl libpng libusbx libxcrypt-compat libxkbcommon make memstrack openssl-pkcs11 os-prober patch pciutils pciutils-libs perl-AutoLoader perl-B perl-Data-Dumper perl-Digest perl-Digest-MD5 perl-FileHandle perl-IO-Socket-IP perl-IO-Socket-SSL perl-Mozilla-CA perl-NDBM_File perl-Net-SSLeay perl-URI perl-Unicode-Normalize perl-base perl-libnet protobuf-c python-unversioned-command python3-dateutil python3-dbus python3-dnf-plugins-core python3-six python3-unbound rdma-core rpm-plugin-systemd-inhibit trousers trousers-lib unbound-libs xkeyboard-config
　# rpm -e \`rpm -qa | grep el7\`
　# rpm -e \`rpm -qa | grep el8\`
　# ln -sf /usr/bin/ros /sbin/shutdown （元のsymlinkの修復）
　# shutdown -r now