December 12, 2020

CentOS Linux 8をCentOS Streamに変更する

CentOS Linux 8がCentOS Streamへシフトすることになったけど、CentOS StreamはCentOS Linuxのローリングリリース版という認識だったので、にっしーはこれといって混乱はなく。 じゃあ、既に稼働中のCentOS Linux 8をCentOS Streamに変更するにはどうすればいいのよ?と調べてみた。

結論

公式手順に従えばいいよ!

実際にやってみた

vagrantでCentOS 8の環境を用意した。

vagrant init centos/8
vagrant up

バージョン確認

[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 8.3.2011

CentOS Streamのリポジトリをインストールする。

[vagrant@localhost ~]$ sudo dnf install centos-release-stream -y

何がインストールされるかというと…

[vagrant@localhost ~]$ rpm -ql centos-release-stream
/etc/dnf/vars/stream
/etc/yum.repos.d/CentOS-Stream-AppStream.repo
/etc/yum.repos.d/CentOS-Stream-Base.repo
/etc/yum.repos.d/CentOS-Stream-Debuginfo.repo
/etc/yum.repos.d/CentOS-Stream-Extras.repo
/etc/yum.repos.d/CentOS-Stream-Media.repo
/etc/yum.repos.d/CentOS-Stream-PowerTools.repo
/etc/yum.repos.d/CentOS-Stream-Sources.repo
/etc/yum.repos.d/CentOS-Stream-Vault.repo
/etc/yum.repos.d/CentOS-Stream-centosplus.repo

EPELのリポジトリ追加するのにsudo dnf install epel-releaseするみたいなものですね。

.repoファイルを整理する

[vagrant@localhost ~]$ sudo dnf swap centos-{linux,stream}-repos
Failed to set locale, defaulting to C
Last metadata expiration check: 0:01:50 ago on Sat Dec 12 04:03:48 2020.
Dependencies resolved.
====================================================================================================
 Package                         Arch             Version             Repository               Size
====================================================================================================
Installing:
 centos-stream-release           noarch           8.4-1.el8           Stream-BaseOS            21 k
     replacing  centos-linux-release.noarch 8.3-1.2011.el8
     replacing  centos-release-stream.x86_64 8.1-1.1911.0.7.el8
 centos-stream-repos             noarch           8-2.el8             Stream-BaseOS            19 k
Removing:
 centos-linux-repos              noarch           8-2.el8             @BaseOS                  26 k

Transaction Summary
====================================================================================================
Install  2 Packages
Remove   1 Package

Total download size: 40 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): centos-stream-repos-8-2.el8.noarch.rpm                        17 kB/s |  19 kB     00:01
(2/2): centos-stream-release-8.4-1.el8.noarch.rpm                    20 kB/s |  21 kB     00:01
----------------------------------------------------------------------------------------------------
Total                                                                16 kB/s |  40 kB     00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                            1/1
  Running scriptlet: centos-stream-repos-8-2.el8.noarch                                         1/1
  Installing       : centos-stream-repos-8-2.el8.noarch                                         1/5
  Installing       : centos-stream-release-8.4-1.el8.noarch                                     2/5
  Obsoleting       : centos-release-stream-8.1-1.1911.0.7.el8.x86_64                            3/5
  Obsoleting       : centos-linux-release-8.3-1.2011.el8.noarch                                 4/5
  Erasing          : centos-linux-repos-8-2.el8.noarch                                          5/5
  Running scriptlet: centos-linux-repos-8-2.el8.noarch                                          5/5
  Verifying        : centos-stream-release-8.4-1.el8.noarch                                     1/5
  Verifying        : centos-linux-release-8.3-1.2011.el8.noarch                                 2/5
  Verifying        : centos-release-stream-8.1-1.1911.0.7.el8.x86_64                            3/5
  Verifying        : centos-stream-repos-8-2.el8.noarch                                         4/5
  Verifying        : centos-linux-repos-8-2.el8.noarch                                          5/5

Installed:
  centos-stream-release-8.4-1.el8.noarch             centos-stream-repos-8-2.el8.noarch

Removed:
  centos-linux-repos-8-2.el8.noarch

Complete!

何が変わったのか、あらかじめcpしておいた.repoファイルとdiffるとこんな感じ

[vagrant@localhost ~]$ diff -ur yum.repos.old/ /etc/yum.repos.d/
Only in yum.repos.old/: CentOS-Linux-AppStream.repo
Only in yum.repos.old/: CentOS-Linux-BaseOS.repo
Only in yum.repos.old/: CentOS-Linux-ContinuousRelease.repo
Only in yum.repos.old/: CentOS-Linux-Debuginfo.repo
Only in yum.repos.old/: CentOS-Linux-Devel.repo
Only in yum.repos.old/: CentOS-Linux-Extras.repo
Only in yum.repos.old/: CentOS-Linux-FastTrack.repo
Only in yum.repos.old/: CentOS-Linux-HighAvailability.repo
Only in yum.repos.old/: CentOS-Linux-Media.repo
Only in yum.repos.old/: CentOS-Linux-Plus.repo
Only in yum.repos.old/: CentOS-Linux-PowerTools.repo
Only in yum.repos.old/: CentOS-Linux-Sources.repo
diff -ur yum.repos.old/CentOS-Stream-AppStream.repo /etc/yum.repos.d/CentOS-Stream-AppStream.repo
--- yum.repos.old/CentOS-Stream-AppStream.repo	2019-12-19 18:32:11.000000000 +0000
+++ /etc/yum.repos.d/CentOS-Stream-AppStream.repo	2020-11-10 00:32:00.000000000 +0000
@@ -1,20 +1,17 @@
-# CentOS-AppStream.repo
-#
-# The mirror system uses the connecting IP address of the client and the
-# update status of each mirror to pick mirrors that are updated to and
-# geographically close to the client.  You should use this for CentOS updates
-# unless you are manually picking other mirrors.
-#
-# If the mirrorlist= does not work for you, as a fall back you can try the
-# remarked out baseurl= line instead.
+# CentOS-Stream-AppStream.repo
 #
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client.  You should use this for CentOS updates unless you are
+# manually picking other mirrors.
 #
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.

-[Stream-AppStream]
-name=CentOS-Stream - AppStream
+[appstream]
+name=CentOS Stream $releasever - AppStream
 mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra
 #baseurl=http://mirror.centos.org/$contentdir/$stream/AppStream/$basearch/os/
 gpgcheck=1
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
-
Only in yum.repos.old/: CentOS-Stream-Base.repo
Only in /etc/yum.repos.d/: CentOS-Stream-BaseOS.repo
diff -ur yum.repos.old/CentOS-Stream-Debuginfo.repo /etc/yum.repos.d/CentOS-Stream-Debuginfo.repo
--- yum.repos.old/CentOS-Stream-Debuginfo.repo	2019-12-19 18:32:11.000000000 +0000
+++ /etc/yum.repos.d/CentOS-Stream-Debuginfo.repo	2020-11-10 00:32:00.000000000 +0000
@@ -1,21 +1,11 @@
-# CentOS-Debug.repo
-#
-# The mirror system uses the connecting IP address of the client and the
-# update status of each mirror to pick mirrors that are updated to and
-# geographically close to the client.  You should use this for CentOS updates
-# unless you are manually picking other mirrors.
+# CentOS-Stream-Debuginfo.repo
 #
+# All debug packages are merged into a single repo, split by basearch, and are
+# not signed.

-# All debug packages from all the various CentOS-8 releases
-# are merged into a single repo, split by BaseArch
-#
-# Note: packages in the debuginfo repo are currently not signed
-#
-
-[Stream-base-debuginfo]
-name=CentOS-Stream - Debuginfo
+[debuginfo]
+name=CentOS Stream $releasever - Debuginfo
 baseurl=http://debuginfo.centos.org/$stream/$basearch/
 gpgcheck=1
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
-
diff -ur yum.repos.old/CentOS-Stream-Extras.repo /etc/yum.repos.d/CentOS-Stream-Extras.repo
--- yum.repos.old/CentOS-Stream-Extras.repo	2019-12-19 18:32:11.000000000 +0000
+++ /etc/yum.repos.d/CentOS-Stream-Extras.repo	2020-11-10 00:32:00.000000000 +0000
@@ -1,21 +1,17 @@
-# CentOS-Extras.repo
-#
-# The mirror system uses the connecting IP address of the client and the
-# update status of each mirror to pick mirrors that are updated to and
-# geographically close to the client.  You should use this for CentOS updates
-# unless you are manually picking other mirrors.
-#
-# If the mirrorlist= does not work for you, as a fall back you can try the
-# remarked out baseurl= line instead.
+# CentOS-Stream-Extras.repo
 #
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client.  You should use this for CentOS updates unless you are
+# manually picking other mirrors.
 #
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.

-#additional packages that may be useful
-[Stream-extras]
-name=CentOS-Stream - Extras
+[extras]
+name=CentOS Stream $releasever - Extras
 mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras&infra=$infra
 #baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/os/
 gpgcheck=1
 enabled=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
-
Only in /etc/yum.repos.d/: CentOS-Stream-HighAvailability.repo
diff -ur yum.repos.old/CentOS-Stream-Media.repo /etc/yum.repos.d/CentOS-Stream-Media.repo
--- yum.repos.old/CentOS-Stream-Media.repo	2019-12-19 18:32:11.000000000 +0000
+++ /etc/yum.repos.d/CentOS-Stream-Media.repo	2020-11-10 00:32:00.000000000 +0000
@@ -1,18 +1,10 @@
-# CentOS-Media.repo
+# CentOS-Stream-Media.repo
 #
-#  This repo can be used with mounted DVD media, verify the mount point for
-#  CentOS-8.  You can use this repo and yum to install items directly off the
-#  DVD ISO that we release.
-#
-# To use this repo, put in your DVD and use it with the other repos too:
-#  yum --enablerepo=c8-media [command]
-#
-# or for ONLY the media repo, do this:
-#
-#  yum --disablerepo=\* --enablerepo=c8-media [command]
+# You can use this repo to install items directly off the installation media.
+# Verify your mount point matches one of the below file:// paths.

-[c8-Stream-media-BaseOS]
-name=CentOS-Stream-BaseOS - Media
+[media-baseos]
+name=CentOS Stream $releasever - Media - BaseOS
 baseurl=file:///media/CentOS/BaseOS
         file:///media/cdrom/BaseOS
         file:///media/cdrecorder/BaseOS
@@ -20,8 +12,8 @@
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

-[c8-Stream-media-AppStream]
-name=CentOS-Stream-AppStream - Media
+[media-appstream]
+name=CentOS Stream $releasever - Media - AppStream
 baseurl=file:///media/CentOS/AppStream
         file:///media/cdrom/AppStream
         file:///media/cdrecorder/AppStream
diff -ur yum.repos.old/CentOS-Stream-PowerTools.repo /etc/yum.repos.d/CentOS-Stream-PowerTools.repo
--- yum.repos.old/CentOS-Stream-PowerTools.repo	2019-12-19 18:32:11.000000000 +0000
+++ /etc/yum.repos.d/CentOS-Stream-PowerTools.repo	2020-11-10 00:32:00.000000000 +0000
@@ -1,20 +1,17 @@
-# CentOS-PowerTools.repo
-#
-# The mirror system uses the connecting IP address of the client and the
-# update status of each mirror to pick mirrors that are updated to and
-# geographically close to the client.  You should use this for CentOS updates
-# unless you are manually picking other mirrors.
-#
-# If the mirrorlist= does not work for you, as a fall back you can try the
-# remarked out baseurl= line instead.
+# CentOS-Stream-PowerTools.repo
 #
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client.  You should use this for CentOS updates unless you are
+# manually picking other mirrors.
 #
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.

-[Stream-PowerTools]
-name=CentOS-Stream - PowerTools
+[powertools]
+name=CentOS Stream $releasever - PowerTools
 mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools&infra=$infra
 #baseurl=http://mirror.centos.org/$contentdir/$stream/PowerTools/$basearch/os/
 gpgcheck=1
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
-
Only in /etc/yum.repos.d/: CentOS-Stream-RealTime.repo
Only in yum.repos.old/: CentOS-Stream-Sources.repo
Only in yum.repos.old/: CentOS-Stream-Vault.repo
Only in yum.repos.old/: CentOS-Stream-centosplus.repo

リポジトリがCentOS Streamを向いたのでdistro-syncする。

[vagrant@localhost ~]$ sudo dnf distro-sync -y

無事CentOS Streamに変わりました。

[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Stream release 8

以降はsudo dnf upgradeしていけば良さそう。

一次情報源

Converting from CentOS Linux to CentOS Stream

© 2020 nissy-lab.com