Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a situation where the stock repo files that should exist in /etc/yum.repos.d/ (like centos-base.repo) are not present. I need to get them installed. I am sure this is simple, but after hours of searching, it seems I am not googling it correctly.

Basically I have a server with custom repos that are useless to me. I need epel, and epel needs centos-base.repo. I also need postgres repo.

share|improve this question
    
or u can install OS on a virtual machine and later copy the default file located in yum.repos.d directory –  OmiPenguin Oct 23 '12 at 12:33

2 Answers 2

Create a file called Centos-Base.repo in the following directory /etc/yum.repos.d Put the following info inside of the file:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=
$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=2




Save it and run 
#yum clean all 

Then run
#yum repolist

If you're copying this into putty via VI then make sure you double check line breaks. I had to fix some editing that happened during the copy-paste.

share|improve this answer
1  
Instead of pasting into an editor like vi or vim, just use cat > filename and press ctrl-d after pasting. Also, vim has a mode designed for receiving data from the clipboard, which will disable auto formatting, etc. Just use ":set paste" before entering insert mode. But I still prefer the cat method, it's simpler. –  Watcom Jan 15 at 19:20

You could manually reinstall the centos-release-rpm using

rpm -ivh --replacepkgs --replacefiles centos-release*.rpm.

share|improve this answer
2  
This worked, but it needed modification. The first step is to see if the centos-release package is installed, by typing rpm -q centos-release. If it's not installed, then the --replacepkgs --replacefiles part of the command should be omitted. In my case the whole thing had been deinstalled, so I used: rpm -Uvh centos-release.*.rpm –  Jim Oct 24 '12 at 1:29
    
@Jim that must have been a brutal removal of that rpm - without dependency-check. I checked with yum remove centos-release - that should normally deinstall the whole system. –  Nils Oct 24 '12 at 13:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.