DEV Community

Janak Shrestha
Janak Shrestha

Posted on

Configure Local Yum repos

The Nautilus production support team and security team had a meeting last month in which they decided to use local yum repositories for maintaing packages needed for their servers. For now they have decided to configure a local yum repo on Nautilus Backup Server. This is one of the pending items from last month, so please configure a local yum repository on Nautilus Backup Server as per details given below.

a. We have some packages already present at location /packages/downloaded_rpms/ on Nautilus Backup Server.

b. Create a yum repo named localyum and make sure to set Repository ID to localyum. Configure it to use package's location /packages/downloaded_rpms/.

c. Install package samba from this newly created repo.


Introduction

Local Yum repositories are essential in environments without internet access, where consistent package versions are required, or when custom packages need to be maintained. This guide covers the complete process of configuring a local repository and installing packages from it.


Why Use a Local Repository

Local repositories provide offline availability, ensuring systems can install packages without internet connectivity. They guarantee consistent versions across all servers, accelerate installation and updates, support custom packages, and enhance security by controlling exactly which packages are available.


Prerequisites

  • Linux server with root access
  • Directory containing RPM packages (/packages/downloaded_rpms/)
  • Yum installed on the system
  • Basic command-line knowledge

Step-by-Step Configuration

1. Connect to the Server

ssh clint@stbkp01
sudo su -
Enter fullscreen mode Exit fullscreen mode

2. Verify the Packages Directory

ls -la /packages/downloaded_rpms/
Enter fullscreen mode Exit fullscreen mode

Confirm the directory contains the required RPM packages.

3. Create the Repository Directory

mkdir -p /etc/yum.repos.d/
Enter fullscreen mode Exit fullscreen mode

4. Create the Repository Configuration File

cat > /etc/yum.repos.d/localyum.repo << EOF
[localyum]
name=localyum
baseurl=file:///packages/downloaded_rpms/
enabled=1
gpgcheck=0
EOF
Enter fullscreen mode Exit fullscreen mode

5. Verify the Repository

yum repolist all
Enter fullscreen mode Exit fullscreen mode

The output should show the repository as enabled.

6. Install the Package

yum install -y samba
Enter fullscreen mode Exit fullscreen mode

7. Verify Installation

rpm -qa | grep samba
samba --version
Enter fullscreen mode Exit fullscreen mode

Repository Configuration Explained

Parameter Value Description
[localyum] Repository ID Unique identifier
name localyum Human-readable name
baseurl file:///packages/downloaded_rpms/ Package location
enabled 1 Repository active
gpgcheck 0 GPG checking disabled

Complete One-Line Setup

cat > /etc/yum.repos.d/localyum.repo << EOF && yum repolist && yum install -y samba
[localyum]
name=localyum
baseurl=file:///packages/downloaded_rpms/
enabled=1
gpgcheck=0
EOF
Enter fullscreen mode Exit fullscreen mode

Verification Commands

# Check repository
yum repolist | grep localyum

# Check installed packages
rpm -qa | grep samba

# Check package details
rpm -qi samba

# Verify samba version
samba --version
Enter fullscreen mode Exit fullscreen mode

Expected Output

[root@stbkp01 ~]# yum repolist
repo id                                repo name                             status
localyum                               localyum                               enabled

[root@stbkp01 ~]# yum install -y samba
Dependencies resolved.
Installed:
  samba-4.24.5-2.el9.x86_64
Complete!

[root@stbkp01 ~]# rpm -qa | grep samba
samba-4.24.5-2.el9.x86_64
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

Issue: /etc/yum.repos.d/ directory not found
Solution: mkdir -p /etc/yum.repos.d/

Issue: Repository not showing in yum repolist
Solution: Check syntax, verify path, run yum clean all

Issue: GPG key errors
Solution: Set gpgcheck=0 or import the correct key


Summary

  • Repository configured: localyum
  • Package location: /packages/downloaded_rpms/
  • Package installed: samba
  • Repository verified and functioning

The local Yum repository is now ready for use on the server.

Top comments (0)