Server Migration Center (SMC) reports the error "A YUM/DNF repository defined multiple times" when multiple .repo files in /etc/yum.repos.d/ share the same repository identifier (repo ID). Duplicate repo IDs prevent the package manager from resolving which repository to use, causing migration jobs to fail.
Background
Each .repo file in /etc/yum.repos.d/ defines one or more YUM or DNF repositories. A repo ID is the label in square brackets at the start of each repository section—for example, [base], [extras], or [updates]. Repo IDs must be unique across all .repo files. If two or more files define the same repo ID, the package manager cannot resolve 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 -d
This command extracts all repo IDs (lines starting with [) from every .repo file, sorts them, and prints only the duplicates.
To identify which files contain a specific duplicate repo ID, run the following command, replacing [base] with the duplicate repo ID:
grep "\[base\]" /etc/yum.repos.d/*.repo
Example 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
For each duplicate, choose the option that 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.bak
Option B: Rename the repo ID
If both repositories are needed, rename the repo ID in one file so 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.