2

I'm trying to determine the best method to permanently remove .repo files from /etc/yum.repos.d/

I'm able to remove the repo file itself from the folder, however when a yum upgrade is performed, it reappears. Is there a method that someone is aware of that is persistent through a yum upgrade that doesn't restore the default .repo files? Appreciate the help.

  • Is that .repo file is owned by a package? rpm -qf /etc/yum.repos.d/that-file.repo would tell you. – Jeff Schaller Sep 23 at 13:23
  • @JeffSchaller - the .repo is owned by a package, yes. Some context around what is trying to be done. From a corporate standpoint, an OpenStack image is being created where all CentOS*.repo files are being removed and openstack-centos.repo is submitted in place of. – Troy Sep 23 at 14:32
  • The fact that they're CentOS repo files might be important enough to mention in your question. My immediate thought of removing that containing package might not be reasonable, in this case. – Jeff Schaller Sep 23 at 14:46
  • @Troy If you can handle that specific package using rpm instead of yum, perhaps this solution will work: unix.stackexchange.com/a/256265/173368 – Haxiel Sep 23 at 17:31
0

You should be able to leave the filenames in place, perhaps with a comment explaining why they are there, centos-release creates files that are missing, but doesn't update them (such that if you set enabled=0 in something like CentOS-Base.repo it should stay that way).

Alternatively, you could change the repos directory. Packages like centos-release will recreate a missing repo file on a system upgrade. However they will not update /etc/yum.conf As such if you control all your repo files you can add:

reposdir=/etc/use.these.repos/

And place your .repo files in another directory. /etc/yum.repos.d/* will still exist and be updated by system updates, but it will be ignored, only files in /etc/use.these.repos will be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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