How to Create Offline Local YUM Repository on CentOS 7 / RHEL 7 / Scientific Linux 7 / Oracle Linux 7 .  The local YUM repository is the most effective way to perform any type of package installation without any internet connection. If the yum repository has setup with the offline packages anyone with default package configurations. The main aim to create such a offline repository it works faster than online repository which can be configured locally.

How to Create Local YUM Repository on CentOS 7 / RHEL 7 / SL 7 / OL 7

Step-1 (Mount the Local Media)

Mount the local media like CD, DVD, USB stick or ISO image that contains CentOS 7 / RHEL 7 / SL 7 / OL 7 to your PC.

Step-2 (Copy or Extract the Media)

You need to copy the data from your physical media to your local PC where the EL distro is installed. If you have ISO images of EL based distro to root of filesystem.

[root@techbrown ~]# cd /
[root@techbrown /]# mkdir localrepo

Copy the Local Media to localrepo DIR

[root@techbrown /]# cp -rv /media/* /localrepo/

Extract the ISO images to the localrepo DIR
Open the ISO image in Archive Manger the extract it to localrepo DIR.

Step-2 (Remove the Online Repository)
[root@techbrown ~]# rm -rf /etc/yum.repos.d/*
Step-3 (Create Local Repository)
[root@techbrown ~]# vim /etc/yum.repos.d/local.repo
For CentOS 7
[centos7]
name=centos7
baseurl=file:///localrepo/
enabled=1
gpgcheck=0
For RHEL 7
[rhel7]
name=rhel7
baseurl=file:///localrepo/
enabled=1
gpgcheck=0
For SL 7
[sl7]
name=sl7
baseurl=file:///localrepo/
enabled=1
gpgcheck=0
For OL 7
[ol7]
name=ol7
baseurl=file:///localrepo/
enabled=1
gpgcheck=0

to save and exit :wq!

Step-4 (Update the local Repository)

If you need to add local some packages to the repo you need to add to the db of local repository.

[root@techbrown ~]# createrepo /localrepo/
Step-5 (Enable the Local Repository)
[root@techbrown ~]# yum clean all
Sample output
Loaded plugins: fastestmirror, langpacks
Cleaning repos: centos7
Cleaning up everything
Cleaning up list of fastest mirrors
[root@techbrown ~]# yum repolist all
Sample Output
Loaded plugins: fastestmirror, langpacks
centos7 | 3.6 kB 00:00:00
(1/2): centos7/group_gz | 154 kB 00:00:00
(2/2): centos7/primary_db | 5.1 MB 00:00:00
Determining fastest mirrors
repo id repo name status
centos7 centos7 enabled: 8,652
repolist: 8,652
[root@techbrown ~]# yum update
Sample Output
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No packages marked for update
Step-6 (Test the local repository)

Install some package to test the repository

[root@techbrown /]# yum install gimp -y
Sample Output
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 2:gimp-2.8.10-3.el7.x86_64 already installed and latest version
Nothing to do

Final Result

That’s all now you have enabled the offline repository to the respective RHEL based enterprise linux distro you need to configure this for more faster enabled repository. If you have any issues regarding this tutorial you may use the comment section below.