upgrade-centos7-centos8
Linux

Comment mettre à jour CentOS 7 vers CentOS 8?

Dans cet article nous allons voir les étapes pour mettre à jour CentOS 7 vers CentOS 8.

Etape 1 : Installer le depôt EPEL

Installer le dépôt EPEL (Extra Packages for Enterprise Linux) avec la commande suivante :

[root@server ~]# yum install epel-release -y
.
.
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/2): epel/x86_64/primary_db | 7.0 MB 00:00:06
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be updated
---> Package epel-release.noarch 0:7-14 will be an update
--> Finished Dependency Resolution
.
.
Running transaction
Updating : epel-release-7-14.noarch 1/2
Cleanup : epel-release-7-11.noarch 2/2
Verifying : epel-release-7-14.noarch 1/2
Verifying : epel-release-7-11.noarch 2/2
Updated:
epel-release.noarch 0:7-14
Complete!

Etape 2 : Install yum-utils

Ensuite installer le package yum-utils :

[root@server ~]# yum install yum-utils
.
.
.
Running transaction
Installing : python-chardet-2.2.1-3.el7.noarch 1/4
Installing : python-kitchen-1.1.1-5.el7.noarch 2/4
Installing : libxml2-python-2.9.1-6.el7.5.x86_64 3/4
Installing : yum-utils-1.1.31-54.el7_8.noarch 4/4
Verifying : libxml2-python-2.9.1-6.el7.5.x86_64 1/4
Verifying : python-kitchen-1.1.1-5.el7.noarch 2/4
Verifying : yum-utils-1.1.31-54.el7_8.noarch 3/4
Verifying : python-chardet-2.2.1-3.el7.noarch 4/4
Installed:
yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
libxml2-python.x86_64 0:2.9.1-6.el7.5 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
Complete!

Tapez ensuite les deux commandes ci-dessous :

[root@server ~]# yum install rpmconf
[root@server ~]# rpmconf -a

effectuez un nettoyage de tous les packages dont vous n’avez pas besoin :

[root@server ~]# package-cleanup --leaves
Loaded plugins: fastestmirror
libsysfs-2.1.0-16.el7.x86_64
libtool-2.4.2-22.el7_3.x86_64
[root@server ~]# package-cleanup --orphans
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: mirror.conwan.ma
epel: mirror.conwan.ma
extras: mirror.conwan.ma
updates: mirror.conwan.ma

Etape 3 : installer dnf

dnf est le gestionnaire par défaut de CentOS 8 il faut donc l’installer :

[root@server ~]# yum install dnf
.
.
Total download size: 357 k
Installed size: 1.6 M
Is this ok [y/d/N]: y
Downloading packages:
dnf-4.0.9.2-2.el7_9.noarch.rpm | 357 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : dnf-4.0.9.2-2.el7_9.noarch 1/1
Verifying : dnf-4.0.9.2-2.el7_9.noarch 1/1
Installed:
dnf.noarch 0:4.0.9.2-2.el7_9
Complete!

Nous devons maintenant désinstaller le gestionnaire de package yum :

[root@server ~]# dnf -y remove yum yum-metadata-parser
.
.
Running transaction
Preparing : 1/1
Erasing : yum-utils-1.1.31-54.el7_8.noarch 1/4
Erasing : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch 2/4
Erasing : yum-3.4.3-168.el7.centos.noarch 3/4
Erasing : yum-metadata-parser-1.1.4-10.el7.x86_64 4/4
Verifying : yum-3.4.3-168.el7.centos.noarch 1/4
Verifying : yum-metadata-parser-1.1.4-10.el7.x86_64 2/4
Verifying : yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch 3/4
Verifying : yum-utils-1.1.31-54.el7_8.noarch 4/4
Removed:
yum-3.4.3-168.el7.centos.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch yum-utils-1.1.31-54.el7_8.noarch
Complete!

Supprimer le contenu de /etc/yum :

[root@server ~]# rm -Rf /etc/yum

Etape 4 : Mettre à jour CentOS avec dnf

Nous allons maintenant mettre à jours notre système avec le nouveau gestionnaire de package dnf :

[root@server ~]# dnf upgrade

Etape 5: Mettre à jour CentOS 7 vers CentOS 8

[root@server ~]# dnf install http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-linux-repos-8-2.el8.noarch.rpm,centos-linux-release-8.4-1.2105.el8.noarch.rpm,centos-gpg-keys-8-2.el8.noarch.rpm}
Last metadata expiration check: 0:07:12 ago on Tue 14 Sep 2021 04:19:26 AM EDT.
centos-linux-repos-8-2.el8.noarch.rpm 24 kB/s | 20 kB 00:00
centos-linux-release-8.4-1.2105.el8.noarch.rpm 47 kB/s | 22 kB 00:00
centos-gpg-keys-8-2.el8.noarch.rpm 34 kB/s | 12 kB 00:00
Dependencies resolved.

Ensuite mettez à jour EPEL :

[root@server ~]# dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
Extra Packages for Enterprise Linux 7 - x86_64 1.0 MB/s | 17 MB 00:16
CentOS Linux 8 - BaseOS 1.0 MB/s | 6.5 MB 00:06
CentOS Linux 8 - AppStream 1.1 MB/s | 8.8 MB 00:08
CentOS Linux 8 - Extras 48 kB/s | 10 kB 00:00
epel-release-latest-8.noarch.rpm 28 kB/s | 23 kB 00:00
Dependencies resolved.
Package Arch Version Repository Size
Upgrading:
epel-release noarch 8-13.el8 @commandline 23 k
Transaction Summary
Upgrade 1 Package
Total size: 23 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : epel-release-8-13.el8.noarch 1/2
Cleanup : epel-release-7-14.noarch 2/2
Verifying : epel-release-8-13.el8.noarch 1/2
Verifying : epel-release-7-14.noarch 2/2
Upgraded:
epel-release-8-13.el8.noarch
Complete!

Supprimer les fichiers temporaires :

[root@server ~]# dnf clean all
55 files removed

Supprimer ensuite les anciens Kernel avec la commande suivante :

[root@server ~]# rpm -e rpm -q kernel

Ensuite, assurez-vous de supprimer les packages en conflit :

[root@server ~]# rpm -e --nodeps sysvinit-tools

Lancez maintenant la mise à jour du système avec la commande suivante ( cela prendrait plusieurs minutes ) :

[root@server ~]# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
.
.
.
Key imported successfully
Running transaction check
Error: transaction check vs depsolve:
(gcc >= 8 with gcc < 9) is needed by annobin-9.50-1.el8.x86_64 rpmlib(RichDependencies) <= 4.12.0-1 is needed by annobin-9.50-1.el8.x86_64 (NetworkManager >= 1.20 or dhclient) is needed by dracut-network-049-135.git20210121.el8.x86_64
rpmlib(RichDependencies) <= 4.12.0-1 is needed by dracut-network-049-135.git20210121.el8.x86_64
(annobin if gcc) is needed by redhat-rpm-config-125-1.el8.noarch
rpmlib(RichDependencies) <= 4.12.0-1 is needed by redhat-rpm-config-125-1.el8.noarch
To diagnose the problem, try running: 'rpm -Va --nofiles --nodigest'.
You probably have corrupted RPMDB, running 'rpm --rebuilddb' might fix the issue.
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.

Etape 6: Installer le nouveau Kernel pour CentOS8 :

[root@server ~]# dnf -y install kernel-core

Si des erreurs s’affiche comme ci-dessous, ajouter l’option :

Last metadata expiration check: 0:28:10 ago on Tue 14 Sep 2021 04:44:14 AM EDT.
Error:
Problem: conflicting requests
package kernel-core-4.18.0-305.10.2.el8_4.x86_64 conflicts with kexec-tools < 2.0.20-8 provided by kexec-tools-2.0.15-51.el7_9.3.x86_64
package kernel-core-4.18.0-305.12.1.el8_4.x86_64 conflicts with kexec-tools < 2.0.20-8 provided by kexec-tools-2.0.15-51.el7_9.3.x86_64
package kernel-core-4.18.0-305.17.1.el8_4.x86_64 conflicts with kexec-tools < 2.0.20-8 provided by kexec-tools-2.0.15-51.el7_9.3.x86_64
package kernel-core-4.18.0-305.3.1.el8.x86_64 conflicts with kexec-tools < 2.0.20-8 provided by kexec-tools-2.0.15-51.el7_9.3.x86_64
package kernel-core-4.18.0-305.7.1.el8_4.x86_64 conflicts with kexec-tools < 2.0.20-8 provided by kexec-tools-2.0.15-51.el7_9.3.x86_64
problem with installed package kexec-tools-2.0.15-51.el7_9.3.x86_64
package kexec-tools-2.0.20-46.el8.x86_64 requires dracut >= 049-129, but none of the providers can be installed
package kexec-tools-2.0.20-46.el8_4.1.x86_64 requires dracut >= 049-129, but none of the providers can be installed
package kexec-tools-2.0.20-46.el8_4.2.x86_64 requires dracut >= 049-129, but none of the providers can be installed
[root@server ~]# dnf -y --allowerasing install kernel-core

En fin installer CentOS 8 ( la version minimale) :

[root@server ~]# dnf -y groupupdate "Core" "Minimal Install"

Vérifiez maintenant la version avec la commande ci-dessous :

[root@server ~]# cat /etc/redhat-release
CentOS Linux release 8.4.2105
centos8

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *