Creating local rpm repositories is one of the objectives of the RHCSA exam. This short post illustrates how to:

  • create a local rpm repository
  • install rpm packages from the repositoy

List repositories:

[[email protected] yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.heanet.ie
 * epel: fedora.kiewel-online.ch
 * extras: ftp.heanet.ie
 * updates: ftp.heanet.ie
repo id                               repo name                                                           status
base/7/x86_64                         CentOS-7 - Base                                                      9,363
epel/x86_64                           Extra Packages for Enterprise Linux 7 - x86_64                      11,476
extras/7/x86_64                       CentOS-7 - Extras                                                      311
updates/7/x86_64                      CentOS-7 - Updates                                                   1,126
repolist: 22,297

Create a directory for our local repo:

[[email protected] yum.repos.d]# mkdir /virtbox

Create rpm repository in the newly created dir:

[[email protected] yum.repos.d]# createrepo /virtbox
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[[email protected] yum.repos.d]# ls -lt /virtbox/
total 4
drwxr-xr-x. 2 root root 4096 Apr 10 21:57 repodata

Add rpm package(s) to the repo:

[[email protected] yum.repos.d]# ls /vboxrepo/
repodata  VirtualBox-5.1-5.1.18_114002_el7-1.x86_64.rpm

Create repository .repo config file:

[[email protected] yum.repos.d]# vim virtbox.repo
[[email protected] yum.repos.d]# cat virtbox.repo
[virtbox]
name = virtbox
baseurl = file:///virtbox
gpgcheck = 0

List repositories:

[[email protected] yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.heanet.ie
 * epel: fedora.kiewel-online.ch
 * extras: ftp.heanet.ie
 * updates: ftp.heanet.ie
repo id                               repo name                                                           status
base/7/x86_64                         CentOS-7 - Base                                                      9,363
epel/x86_64                           Extra Packages for Enterprise Linux 7 - x86_64                      11,476
extras/7/x86_64                       CentOS-7 - Extras                                                      311
updates/7/x86_64                      CentOS-7 - Updates                                                   1,126
virtbox                               virtbox                                                                  1
repolist: 22,297

Install rpm package from our new repo:

[[email protected] yum.repos.d]# yum install VirtualBox-5.1
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.heanet.ie
 * epel: fedora.kiewel-online.ch
 * extras: ftp.heanet.ie
 * updates: ftp.heanet.ie
Resolving Dependencies
--> Running transaction check
---> Package VirtualBox-5.1.x86_64 0:5.1.18_114002_el7-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================
 Package                     Arch                Version                             Repository            Size
================================================================================================================
Installing:
 VirtualBox-5.1              x86_64              5.1.18_114002_el7-1                 virtbox               75 M

Transaction Summary
================================================================================================================
Install  1 Package

Total download size: 75 M
Installed size: 168 M
Is this ok [y/d/N]: y
[. . .]
  Verifying  : VirtualBox-5.1-5.1.18_114002_el7-1.x86_64                                                    1/1 

Installed:
  VirtualBox-5.1.x86_64 0:5.1.18_114002_el7-1                                                                   

Complete!

Congrats! We’ve just installed VirtualBox rpm package form our virtbox local repository!