Introduction#
Given the limited selection of images provided by Tencent Cloud's lightweight server, it is not possible to directly obtain the Rocky Linux 9 image. Therefore, it has been decided to manually migrate the existing CentOS Stream 9 (referred to as CS 9) system. The migration script provided by Rocky Linux was used, and the following are the encountered problems and their solutions.
Migration#
For CS 8, simply follow the official tutorial and there should be no issues similar to CS 9 when tested.
Obtain the script#
curl https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh -o migrate2rocky9.sh
If the network is poor in China, you can use the GitHub acceleration service provided by stilleshan.
curl https://mirror.ghproxy.com/https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh -o migrate2rocky9.sh
Downloading first and then uploading is also acceptable.
Execute the script installation#
Grant executable permission to the script.
chmod +x migrate2rocky.sh
Execute the script.
./migrate2rocky.sh -r
When executing the script, consider using screen or tmux to avoid system crashes caused by interrupted connections.
Encountered Problems and Initial Analysis#
When attempting to use the official migration script for Rocky Linux 9, an error message regarding the CentOS-Stream-BaseOS.repo
file was encountered, indicating that the package providing the file could not be found.
Error: No matches found. ...
Can't get package that provides /etc/yum.repos.d/CentOS-Stream-BaseOS.repo.
Upon inspection, the contents of CentOS-Stream-BaseOS.repo
are as follows:
[baseos]
name=CentOS Stream $releasever - BaseOS
baseurl=http://mirrors.tencentyun.com/$contentdir/$stream/BaseOS/$basearch/os/
At the same time, no relevant CS 9 images were found in Tencent Cloud's image library, only CS 8 image resources were found. Based on this, it is speculated that Tencent Cloud has not yet provided CS 9 images, or it has adopted non-standard image paths, causing the Rocky script to fail to correctly identify and locate the required package paths.
Solution Process#
Approach#
Switch to the CS 9 mirror source provided by Tsinghua University and try the migration script again.
Execution#
- Create a backup directory and backup all files under
/etc/yum.repos.d/
to/root/backup/
. - Replace the mirror source according to the tutorial from Tsinghua University Mirror Site. Obtain the new
centos.repo
andcentos-addons.repo
files. - Clean and rebuild the package cache
dnf clean all && dnf makecache
. - Run the script again.
Problems#
Dependency module issue#
When executing the update_mirror.pl
script recommended by the Tsinghua University mirror site to update the mirror source address, an error regarding the missing autodie.pm
module occurred. This problem was resolved by searching for and installing the perl-autodie.noarch
module using the dnf
tool.
dnf install perl-autodie.noarch
Configuration duplication issue#
However, after executing the dnf
command, it was found that multiple repositories were listed multiple times. This is because Tencent Cloud has scattered the repository information of CentOS Stream across different files, resulting in the original sources still existing after the replacement. To eliminate this issue, it is necessary to delete the duplicate definitions. I directly deleted the original files. Note: This operation should be performed after completing the replacement using the script provided in the Tsinghua University tutorial.
rm CentOS-Stream-*.repo
Finally, run the Rocky Linux migration script ./migrate2rocky.sh -r
to complete the migration from CentOS Stream 9 to Rocky Linux 9.
Others#
It is also possible to directly delete the original files and then copy and paste the files from the Tsinghua University mirror site, but attention should be paid to permission issues.
It seems that the script has requirements regarding the case sensitivity of file names. If the script fails to execute, consider modifying the file names to centos.repo
and centos-addons.repo
.