Server Migration Center (SMC) reports the error "A YUM/DNF repository defined multiple times" when multiple .repo configuration files in /etc/yum.repos.d/ define the same repository identifier (repo ID). This conflict can cause operating system migration jobs to fail.
Background
Each .repo file in /etc/yum.repos.d/ defines one or more YUM or DNF repositories. A repository identifier is the label in square brackets at the beginning of each repository section, such as [base], [extras], or [updates]. Each repo ID must be unique across all .repo files. When two or more files define the same repo ID, the package manager cannot determine which repository to use, and SMC reports this error.
Solution
Step 1: Connect to the instance
Connect to the Elastic Compute Service (ECS) instance whose operating system you want to migrate. For details, see Connect to a Linux instance by using a password or key.
Step 2: Find duplicate repo IDs
Run the following command to list all duplicate repo IDs across every .repo file:
grep -h '^\[' /etc/yum.repos.d/*.repo | sort | uniq -dThis command extracts all repo IDs (lines starting with [) from every .repo file, sorts them, and prints only the duplicates.
To see which files contain a specific duplicate, run:
grep "\[base\]" /etc/yum.repos.d/*.repoExample output:
/etc/yum.repos.d/CentOS-7.repo:[base]
/etc/yum.repos.d/CentOS-Base.repo:[base]In this example, both CentOS-7.repo and CentOS-Base.repo define the [base] repo ID.
Step 3: Remove the duplicates
Pick one of the following approaches for each duplicate. Use the approach that best fits your situation.
Option A: Remove the redundant file (recommended)
If one .repo file is outdated or redundant, back it up and remove it:
mv /etc/yum.repos.d/CentOS-7.repo /etc/yum.repos.d/CentOS-7.repo.bakOption B: Rename the repo ID
If both repositories are needed, rename the repo ID in one of the files so that each repository has a unique identifier:
# Before
[base]
# After
[base-alt]If multiple repo IDs are duplicated (such as[base],[extras], and[updates]), resolve each one. Re-run the command from Step 2 to confirm no duplicates remain.
Step 4: Retry the migration
After resolving all duplicates, run the SMC client and retry the migration job. For details, see Run the SMC client.