DEV Community

Cover image for How to Create a Linux Local Repository
Samuel Ajisafe
Samuel Ajisafe

Posted on

1

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, 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
Enter fullscreen mode Exit fullscreen mode

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/
Enter fullscreen mode Exit fullscreen mode

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

sudo vi /etc/yum.repos.d/local-repo.repo
Enter fullscreen mode Exit fullscreen mode

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

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

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

sudo yum repolist
Enter fullscreen mode Exit fullscreen mode

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/
Enter fullscreen mode Exit fullscreen mode

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

Billboard image

Monitoring as code

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay