Taoheedene
Mission Specialist
Mission Specialist
  • 1,392 Views

Creating Local Repository in CentOS Stream 9

Jump to solution

I’m using CentOS-Stream-9 for my Linux VM.

/ is the directory I have my localrepo(which includes everything I have copied from my CentOS dvd.


Now, I want to create a local repository as thus

[root@MyFirstLinuxOS yum.repos.d]# vi local.repo

[centos-stream-9]
name=CentOS-Stream-9
baseurl=file:///localrepo/
enabled=1
gpgcheck=0

However, I get the errror
bash: createrepo: command not found ….
Failed to search for file: reposdata local was not complete: Cannot open /localrepo/repdata/repomd.xml: No such file or directory

What do I need to do to create the local repository, please?

2 Solutions

Accepted Solutions
Travis
Moderator
Moderator
  • 1,147 Views

@Taoheedene -

You have a chicken and egg scenario here. It appears you are trying to setup a local repository from a CentOS stream image. It looks like you are creating a REPO file and pointing to a directory on your machine called localrepo

It then looks like you are attempting to install the createrepo command so you can use it to create a repo. Unfortunately, when you create a <something.repo> file in /etc/yum.repos.d/<something.repo> and it is invalid, it prevents any installation from happening as you have corrupted repos (especially if that is the repo you are trying to use). 

It would be best to install the createrepo command from the DVD ISO and then run the createrepo command on the directory before creating the REPO configuration file.

The error message you have above also indicates that for your BASEOS that you also possbily have some issues and I would guess spelling as it is looking for morrors and not mirrors for the DNS name, so there is no way to resolve that, again, preventing you from installing the createrepo command.

It might be possible to mount the CentOS DVD ISO and then recursively copy all the contents to your local system in the /localrepo directory and then it should already be setup like the DVD which *should* already have the repo metadata files created. As the file in your original post shows, you should have all RPMs and packages in the /localrepo directory and it should already have the REPO and REPO Metadata present.

I would suggest using the "tree" command on localrepo and seeing the directory structure and all the files. You can use grep to search for a specific name/file along with the tree command, but no matter what (even if createrepo.rpm exists) if the /localrepo directory isn't formatted as a REPO and containing the metadata YUM/DNF will not be able to read or install the applications as it isn't viewed as a valid repository.

Hope this helps.

 

https://access.redhat.com/solutions/1355683

https://www.tecmint.com/create-local-yum-repository-on-centos-8/

 

The above links have pretty decent tutorials on how this can be done for additional information.

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training

View solution in original post

7 Replies
Chetan_Tiwary_
Moderator
Moderator
  • 1,372 Views

@Taoheedene check for createrepo rpm in your localrepo dir and install it using rpm -ivh. Then you can create the repo using createrepo command.

0 Kudos
Taoheedene
Mission Specialist
Mission Specialist
  • 1,353 Views

using the ls -ltr | grep createrepo command
I got three different createrepo rpm, which I believe confirms the presence of the createrepo in the localrepo directory
However, running the command;
ls /localrepo/Packages/createrepo. gave me this error;
ls: cannot access’/localrepo/Packages/createrepo’: No such file or directory



Hence, I was unable to install the createrepo(using the rpm -ivh createrepo command)


Please, what do I do next?

I don’t mind getting on a video call and sharing my screen to get this resolved.

I’m currently learning Linux and don’t want to miss any details in the learning process.


Thank you.

Taoheedene
Mission Specialist
Mission Specialist
  • 1,311 Views
@Chetan_Tiwary_
Please, is there any other thing I can do to resolve this?
Chetan_Tiwary_
Moderator
Moderator
  • 1,271 Views
Taoheedene
Mission Specialist
Mission Specialist
  • 1,172 Views
@Chetan_Tiwary_
Thank you very much for your response. However, I still experienced the following errors at the very last stage.


I wish it was possible to send a picture.

1. After running the yum repolist all command. I got list of repositories. As in:

Repo id. Repo name Status
AppStream. CentOS Stream 9 enabled
appstream-debug ,, ,, disabled
And so on.
However, I didn’t get the total number of the repolist after this. As in;
repolist:3, 871(this is an example)

2. Running the yum install tomcat gave me the following error
CentOS Stream 9 - BaseOS

Errors during downloading metadata for repository ‘baseos’:
-Curl error (6): Couldn’t resolve host name for https://morrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http [could not resolve host: mirrors.centos.org]
Error: Failed to download metadata for repo ‘baseos’ : Cannot prepare internal mirrorlist: Curl error (6): Couldn’t resolve host name for https://morrors.centos.org/metalink?repo=centos-baseos-9-stream&arch=x86_64&protocol=https,http [could not resolve host: mirrors.centos.org]

Travis
Moderator
Moderator
  • 1,148 Views

@Taoheedene -

You have a chicken and egg scenario here. It appears you are trying to setup a local repository from a CentOS stream image. It looks like you are creating a REPO file and pointing to a directory on your machine called localrepo

It then looks like you are attempting to install the createrepo command so you can use it to create a repo. Unfortunately, when you create a <something.repo> file in /etc/yum.repos.d/<something.repo> and it is invalid, it prevents any installation from happening as you have corrupted repos (especially if that is the repo you are trying to use). 

It would be best to install the createrepo command from the DVD ISO and then run the createrepo command on the directory before creating the REPO configuration file.

The error message you have above also indicates that for your BASEOS that you also possbily have some issues and I would guess spelling as it is looking for morrors and not mirrors for the DNS name, so there is no way to resolve that, again, preventing you from installing the createrepo command.

It might be possible to mount the CentOS DVD ISO and then recursively copy all the contents to your local system in the /localrepo directory and then it should already be setup like the DVD which *should* already have the repo metadata files created. As the file in your original post shows, you should have all RPMs and packages in the /localrepo directory and it should already have the REPO and REPO Metadata present.

I would suggest using the "tree" command on localrepo and seeing the directory structure and all the files. You can use grep to search for a specific name/file along with the tree command, but no matter what (even if createrepo.rpm exists) if the /localrepo directory isn't formatted as a REPO and containing the metadata YUM/DNF will not be able to read or install the applications as it isn't viewed as a valid repository.

Hope this helps.

 

https://access.redhat.com/solutions/1355683

https://www.tecmint.com/create-local-yum-repository-on-centos-8/

 

The above links have pretty decent tutorials on how this can be done for additional information.

Travis Michette, RHCA XIII
https://rhtapps.redhat.com/verify?certId=111-134-086
SENIOR TECHNICAL INSTRUCTOR / CERTIFIED INSTRUCTOR AND EXAMINER
Red Hat Certification + Training
Taoheedene
Mission Specialist
Mission Specialist
  • 1,091 Views
@Chetan_Tiwary_
Thank you very much for this document. I had to delete and reinstall VirtualBox and set up the virtual machine again. The tutor in the Linux tutorial I'm following didn't include the installation of the "createrepo" package, which is why I couldn't use it to create a local repository. Your guidance has been invaluable. Thank you so much.

@Travis, your contribution has also been incredibly helpful. I can't thank you enough for your support.
Join the discussion
You must log in to join this conversation.