小版本升级(如7.x→7.y)
sudo yum update -y # 更新所有软件包
sudo yum distro-sync # 同步到最新小版本
sudo reboot
大版本升级(如7→8)
sudo yum install -y epel-release dnf
sudo dnf install centos-release-8 # 安装CentOS 8仓库
sudo dnf system upgrade download --refresh
sudo dnf system upgrade reboot
升级到CentOS Stream(滚动更新)
sudo dnf install centos-release-stream
sudo dnf swap centos-{linux,stream}-repos
sudo dnf distro-sync
sudo reboot
使用rsync(推荐)
sudo rsync -avz --progress /source/ /destination/ # 复制文件
sudo rsync -avz /etc/passwd /etc/shadow /etc/group /destination/etc/ # 复制用户
sudo rsync -avz /etc/fstab /destination/etc/ # 复制分区表
使用Clonezilla(磁盘克隆)
rsync或tar备份所有数据和配置文件。/etc、/var、/home等关键目录。preupgrade-assistant工具检查软件包兼容性。systemctl restart httpd)。参考来源: