DEV Community

Cover image for Your own local repository.
vanquisher
vanquisher

Posted on

Your own local repository.

In this post, I will explain how to create your own local repository in Centos 7.

1.Attach and mount the iso

sudo su - 
mkdir /mnt/cdrom   #create a mount point            
mount /dev/cdrom /mnt/cdrom
df  -h            #verify if mounted 
Enter fullscreen mode Exit fullscreen mode

2.Copy the Packages from iso

ISO comes with inbuilt packages.These packages must have .rpm extension. So, we copy those inbuilt packages to another directory and make it as a new repository.

ls /mnt/cdrom
cp -R  /mnt/cdrom/Packages    /root
Enter fullscreen mode Exit fullscreen mode

3.Create .repo file in /etc/yum.repos.d directory

Create a configuration file with .repo as extension and add these details into it.

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

Filename - local.repo

[localrepo]
name=Prajwal Repository
baseurl=file:///root/Packages
gpgcheck=0
enabled=1
Enter fullscreen mode Exit fullscreen mode

In the above file(ie., local.repo),
'name' is the name of the repo,
'baseurl' is the path to the package directory
'gpgcheck' it takes 0 or 1. It's used for security. Only a user with gpgkey can access this repo if it's set to 1
'enabled' it also take 0 or 1. To activate this repo set it to 1.

4.Building local repository

createrepo is the command to create a repository.

yum info createrepo
yum install createrepo
createrepo -v  /root/Packages 
Enter fullscreen mode Exit fullscreen mode

5.Verify if the repository is successfully created.

yum repolist all | grep -i prajwal  
Enter fullscreen mode Exit fullscreen mode

Cool then!

Discussion (1)

Collapse
lbonanomi profile image
lbonanomi

I like the ISO install instructions! This is super handy for air-gapped environments!