Need to recreate /etc/yum.repolist.d/ repositories for Centos8

Latest response

Hi ,
I was trying to install CRC in my Centos 8 , and by mistake i have deleted /etc/yum.repolist.d/ repositories. I have tried many options and not able to find anything.
Does anybody know how to re-create repositories for /etc/yum.repolist.d

Please help.



Hi Prabhat,

One easy option is to scp those files from another similar working system. If there are no such systems found in your environment, then you could extract all these files from the "centos-repos" package as these configuration files are installed by this package.

You would need to mount the ISO image locally in order to extract the required configuration files. You may follow similar steps as I've mentioned below:

[root@centos8 ~]# mkdir /tmp-repo
[root@centos8 ~]# rpm -qf /etc/yum.repos.d/CentOS-Base.repo
[root@centos8 ~]# cd /tmp-repo/
[root@centos8 tmp-repo]# pwd
[root@centos8 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm | cpio --extract --make-directories --verbose "*.repo"
22 blocks
[root@centos8 tmp-repo]# ls
[root@centos8 tmp-repo]# cd etc/yum.repos.d/
[root@centos8 yum.repos.d]# ls
CentOS-AppStream.repo  CentOS-centosplus.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo       CentOS-Sources.repo
CentOS-Base.repo       CentOS-CR.repo          CentOS-Extras.repo     CentOS-HA.repo         CentOS-PowerTools.repo  CentOS-Vault.repo

Later, you could easily move these files to the desired location '/etc/yum.repos.d/' directory and this should work. The ISO image is mounted under /media.

All the best!

Hi Sadashiv ,

Thanks for reply , i have followed the above step . I couldn't find find iso image under /media . I checked the internt and i am bit confused. I checked my redhat release - CentOS Linux release 8.0.1905 (Core)

When i tried to run the commands , i was getting below error for this command

root@centos8 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm | cpio --extract --make-directories --verbose "*.repo" No such file or directory cpio: premature end of archive

Can you please give me the link from where i can download iso image for "CentOS Linux release 8.0.1905 (Core)". so that i can copy that iso in /media.

Thanks , Prabhat

Hi Prabhat,

Yes, you need to mount the required ISO image under /media or whichever mount as you required and then do a extract as mentioned. Otherwise, you may download the required package alone and do the extract.

I've used the command on CentOS 8.1, so in your case the package version would be different. Check and attach the ISO image of CentOS8.0 to your system first and then you could mount it. Mostly, any CD/DVD/ISO images gets represented by the device /dev/cdrom. So, you get this mounted under media using the command " # mount /dev/cdrom /media ". Once done, extract the required files from centos-repos package as mentioned. This is option one.

Another option, is to download the required package standalone from CentOS mirrors and then extract. Run this command and find out which version of centos-repos package is required.

# rpm -q centos-repos

So, download and move the package to the system and then do extract as mentioned.

Third option is that you could extract those files from another working similar system if you've over there and move those files by doing scp.

You could try downloading the CentOS8.0.1905 using this mirror link:

This link would take you to the complete list of mirror sites for CentOS download;

I hope this helps.

Hi Sadashiva ,

Thanks for the quick reply, i have downloaded an ISO image and i am trying to upload it in my VM through WINscp . I will follow the steps and let you know the results.

Thanks, Prabhat

Hi Sadashiv,

i have downloaded this iso image but i could not find this file under that image /media/BaseOS/Packages/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm .

You would need to extract from the package using "rpm2cpio" command as I explained before.

Hi Prabhat,

Did this work for you? I appreciate if you could provide an update.

Hello Sadashiv , Sorry for the delay in response. I have tried to do the above steps but only problem is , when i am trying to copy the iso file through Winscp in my Vm its showing not enough space after copying around 3 gb . ISO image is of 6.6 g b i am trying to copy in my root path [root@god23807 /]# But its showing not enough space even though

[root@god23807 /]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.7G 0 7.7G 0% /dev tmpfs 7.8G 9.1M 7.8G 1% /dev/shm tmpfs 7.8G 19M 7.7G 1% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/sda4 50G 23G 28G 46% / /dev/sda2 976M 127M 783M 14% /boot /dev/sda1 599M 6.7M 593M 2% /boot/efi /dev/sda5 407G 71G 336G 18% /home tmpfs 1.6G 16K 1.6G 1% /run/user/42 tmpfs 1.6G 8.0M 1.6G 1% /run/user/1000 tmpfs 1.6G 6.8M 1.6G 1% /run/user/0

Where can i copy iso image. Can u tell ?

Thanks, Prabhat

Prabhat, you would either use the ISO image file or download the specified package as I've mentioned before and then extract the required files. If there is a space constraint then you may try downloading the centos-repos package separately using the link

These packages are found under this CentOS mirror site

I hope this helps you.

Hi Sadashiv, Please ignore the above response , this is latest. This command you have given is not working for me .Below are the results

[root@god23807 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm | cpio --extract --make-directories --verbose "*.repo"

rpm2cpio: /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm: No such file or directory cpio: premature end of archive

[root@god23807 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm | cpio --extract --make-directories

rpm2cpio: /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm: No such file or directory cpio: premature end of archive

[root@god23807 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm

rpm2cpio: /media/BaseOS/Packages/centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm: No such file or directory [root@god23807 tmp-repo]#

I have checked this file "centos-repos-8.1-1.1905.0.9.el8.x86_64.rpm" in the BaseOs/Packages/ path ,its not there . File i can find over there is "centos-release-8.1-1.1905.0.9.el8.x86_64.rpm".



Even using this commands doesn't help-

[root@god23807 /]# rpm -qf /etc/yum.repos.d/CentOS-Base.repo


[root@god23807 tmp-repo]# rpm2cpio /media/BaseOS/Packages/centos-release-8.1-1.1905.0.9.el8.x86_64.rpm | cpio --extract --make-directories --verbose "*.repo"

rpm2cpio: /media/BaseOS/Packages/centos-release-8.1-1.1905.0.9.el8.x86_64.rpm: No such file or directory cpio: premature end of archive

Hello Sadashiv,

It worked :) . All repos are back.

Thankyou so much .Your first response was enough to solve this , i might have commented a lot but i tried to find my own errors and and then it worked.

Thanks, Prabhat

I'm glad that it worked! Thanks for reporting Prabhat. Keep learning.... all the best!