centos-migrate-alma-rocky-logo

目标

从 CentOS 8 直接升级为 Rocky Linux 8,在 CentOS 年底生命周期总结后,继续获得 Rocky Linux 长达 8 年的免费支持。

支持的系统

本文适用于 RHEL 8 兼容发行版,包括 REHL 8、CentOS 8、Oracle Linux 8 和 AlmaLinux 8,不过一般只会迁移 CentOS 8 到 Rocky Linux,其他兼容发现都拥有相同长久的生命周期,一般不会考虑迁移到别的发行版。

不限原有 RHEL 8 兼容发行版的具体版本,迁移成功后都为 Rocky Linux 8 的当前最新版。

重要提示

生产环境请务必先备份!!!

迁移步骤

请备份当前系统,非本文讨论范畴,仅作提示!

1. 确认当前系统版本

本例使用 CentOS 8.5.2111 为例,这是最后一版 CentOS。

$ cat /etc/redhat-release
CentOS Linux release 8.5.2111

$ cat /etc/centos-release
CentOS Linux release 8.5.2111

$ uname -a
Linux localhost.sysin.org 4.18.0-348.el8.x86_64 #1 SMP Tue Oct 19 15:14:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

2. 执行迁移

curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh

# 赋予可执行权限:
$ chmod +x ./migrate2rocky.sh

# 查看脚本帮助
$ ./migrate2rocky.sh -h
# 输出如下 (SYSIN)
Usage: migrate2rocky.sh [OPTIONS]

Options:
-h Display this help
-r Convert to rocky
-V Verify switch
   !! USE WITH CAUTION !!

# 执行迁移
$ sudo ./migrate2rocky.sh -r
# 整个过程大约持续数分钟到数十分钟,主要取决于网络状况和软件包数量。
# 笔者测试的最小化安装的空系统几分钟完成了。

raw.githubusercontent.com 可能被墙,
通过 https://www.ipaddress.com 查询,写入 hosts 即可,例如:
sudo sh -c 'echo "185.199.108.133 raw.githubusercontent.com" >> /etc/hosts'

过程如下,这里首次执行报错了。

因为配置了排除特定软件包更新,导致报错:
/etc/yum.conf 中的 exclude=kernel* centos-linux-release
备注:AlmaLinux 不存在该问题。

sudo ./migrate2rocky.sh -r
Removing dnf cache
Preparing to migrate CentOS Linux 8 to Rocky Linux 8.

Determining repository names for CentOS Linux 8.....

Found the following repositories which map from CentOS Linux 8 to Rocky Linux 8:
CentOS Linux 8  Rocky Linux 8
appstream       appstream
baseos          baseos
extras          extras

Getting system package names for CentOS Linux 8......Error: No Matches found

Can't get package that provides system-release.

An error occurred while we were attempting to convert your system to Rocky Linux. Your system may be unstable. Script will now exit to prevent possible damage.

 A log of this installation can be found at /var/log/migrate2rocky.log
再次执行:


...

Complete!

Done, please reboot your system.
A log of this installation can be found at /var/log/migrate2rocky.log

3. 验证迁移结果

# 输出好简单?
Creating a list of RPMs installed: begin
Verifying RPMs installed against RPM database: begin

A log of this installation can be found at /var/log/migrate2rocky.log

# 继续执行如下命令查看
# check release file
$ cat /etc/redhat-release
Rocky Linux release 8.5 (Green Obsidian)

# check that the system boots Rocky Linux kernel by default
$ sudo grubby --info DEFAULT | grep Rocky
title="Rocky Linux (4.18.0-348.2.1.el8_5.x86_64) 8.5 (Green Obsidian)"

4. 重启到 Rocky Linux

sudo reboot

可以看到内核已经出现了 grub 引导画面
centosmigraterockylinux.webp

CentOS 8.5 的启动项显示名称为 CentOS Stream,这里并非 CentOS Stream。

启动成功后,查看内核版本:

$ uname -r
4.18.0-348.2.1.el8_5.x86_64

已知问题
参看 migrate2rocky

请访问原文链接:迁移 CentOS 8 到 Rocky Linux 8,查看最新版。原创作品,转载请保留出处。

作者主页:www.sysin.org