How to create a local yum repository

Yum Server Side

Take a look at the available repositories with the repolist option to yum:

$yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink | 13 kB 00:00
* base: mirror.symnds.com
* epel: epel.mirror.constant.com
* extras: mirrors.advancedhosters.com
* updates: mirrors.lga7.us.voxel.net
base | 3.7 kB 00:00
epel | 4.4 kB 00:00
epel/primary_db | 6.4 MB 00:00
extras | 3.4 kB 00:00
newrelic | 951 B 00:00
shells_fish_release_2 | 1.2 kB 00:00
updates | 3.4 kB 00:00
virtualbox

Add required supporting packages:
$yum install libxml2-python deltarpm python-deltarpm vsftpd

Create a directory to store the rpm files or mount a directory which contains them.
$mkdir /var/ftp/pub/localrepo

Copy rpms to /var/ftp/pub/localrepo
$cp /mnt/disk/*.rpm /var/ftp/pub/localrepo/

Add the repo config file:
$vim /etc/yum.repos.d/localrepo.repo
Add the following lines:

[localrepo]
name=Local Repository
baseurl=file:///var/ftp/pub/localrepo
gpgcheck=0
enabled=1

Build the local repository:
$createrepo -v /var/ftp/pub/localrepo

Now use the yum command that we used above to verify that yum sees the new repo:
$yum repolist

As a good practice, run clean all and update:

$yum clean all
$yum update

Remember to add the repo to any client machine that should have access to it:

Client Side Configuration
Now, go to your client systems. Create a new repository file as shown above under /etc/yum.repos.d/ directory.

$vim /etc/yum.repos.d/localrepo.repo
and add the following contents:

[localrepo]
name=Local Repository
baseurl=ftp://{IP OF LOCALREPO}/pub/localrepo
gpgcheck=0
enabled=1

Now, list out the repositories using the following command:
$yum repolist

Clean the Yum cache and update the repository lists:

$yum clean all
$yum update

About vicki

Welcome to the Sovereign Republic of Vickistan. I am the President here. Lucky me! No taxes or laws yet. Lucky you!
This entry was posted in Linux. Bookmark the permalink.