How to Create a Linux Local Repository

Are you a DevOps Engineer, System Administrator, or System Engineer looking to set up your own custom Linux repository for downloading dependencies or installing software? This guide will walk you through the process of creating a local repository, spe…


This content originally appeared on DEV Community and was authored by Samuel Ajisafe

Are you a DevOps Engineer, System Administrator, or System Engineer looking to set up your own custom Linux repository for downloading dependencies or installing software? This guide will walk you through the process of creating a local repository, specifically using CentOS 7, although the steps are applicable to other Linux distributions as well.

Why Create a Local Repository?
With CentOS 7 reaching its end of support in June 2024, you may find it difficult to install dependencies or download software from the official yum repositories. Setting up a self-managed local repository allows you to continue accessing necessary packages without needing an internet connection.

Steps to Create a Local Repository
Download the .iso Image from the official page of Centos
Download the .iso image of your current installed operating system (CentOS 7).

Create a Directory
Create a directory in the root directory to mount the .iso image. For example:

sudo mkdir -p /repository

Mount the .iso Image
Mount the .iso image to the created directory:

sudo mount /path/to/CentOS-7-x86_64-DVD-1602-99.iso /repository/

Create a Repository File
Create a repository file in the default repository directory:

sudo vi /etc/yum.repos.d/local-repo.repo

Add Repository Configuration
Paste the following configuration into the file and save it:

[localrepo]
name=Local Repository
baseurl=file:///repository
enabled=1
gpgcheck=0

Update Repository List
Update the repository list to include the new local repository:

sudo yum repolist

The new local repository should now appear in the list of repositories.

(Optional) Clean Up Repository Files
If desired, remove all other repository files in the /etc/yum.repos.d/ directory except for files starting with epel.*.

sudo rm /etc/yum.repos.d/* && sudo mv /etc/yum.repos.d/epel.* /etc/yum.repos.d/

Conclusion
Congratulations! You should now be able to download all the dependencies and software you need from your local repository without needing to connect to the internet. This setup ensures you have a reliable source for packages, especially useful for environments with restricted internet access or for maintaining consistent package versions.

SystemEngineer #sysAdmin #systemadministrator #DevOps


This content originally appeared on DEV Community and was authored by Samuel Ajisafe


Print Share Comment Cite Upload Translate Updates
APA

Samuel Ajisafe | Sciencx (2024-07-24T20:56:49+00:00) How to Create a Linux Local Repository. Retrieved from https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/

MLA
" » How to Create a Linux Local Repository." Samuel Ajisafe | Sciencx - Wednesday July 24, 2024, https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/
HARVARD
Samuel Ajisafe | Sciencx Wednesday July 24, 2024 » How to Create a Linux Local Repository., viewed ,<https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/>
VANCOUVER
Samuel Ajisafe | Sciencx - » How to Create a Linux Local Repository. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/
CHICAGO
" » How to Create a Linux Local Repository." Samuel Ajisafe | Sciencx - Accessed . https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/
IEEE
" » How to Create a Linux Local Repository." Samuel Ajisafe | Sciencx [Online]. Available: https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/. [Accessed: ]
rf:citation
» How to Create a Linux Local Repository | Samuel Ajisafe | Sciencx | https://www.scien.cx/2024/07/24/how-to-create-a-linux-local-repository/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.