This guide will help you to exactly accomplish that.We have provided all steps needed to have a working local yum repository created using CentOS DVD ISO image.Below are steps used:
Step 1: Downloading CentOS-7-x86_64-Everything ISO or CentOS 7 DVD ISO image.
I’ll be using CentOS-7-x86_64-Everything ISO image which can be downloaded from download page in Official CentOS 7.You can also use CentOS 7 DVD ISO.
Step 2: Create Mount points and Mount ISO image.
After downloading, we’ll have to mount it.There are two mounting Options we can use:
- Mounting the ISO file to a local directory in our Linux system
a) Create a directory for mounting
b) Mount ISO image of CentOS Everything or CentOS 7 DVD ISO
c) Confirm it’s mounted using du or ls command.
- Mounting the ISO image file to a web server directory.
I’m using Apache server running on another CentOS server.If you’re doing this on any other Linux server, replace the root directory of web server with the one provided here.
a) Create a directory for mounting
The output you get from last command is:
mount: /dev/loop0 is write-protected, mounting read-only
Contents of /var/www/html/centos/ directory should be as shown:
- If you had CentOS 7 DVD ISO image on CD/DVD drive. Create a mount point and mount cdrom using the following commands:
You can see the contents of /mnt/cent/cdrom/
Step 3: Create a repo and put it inside /etc/yum/repos.d/ directory.
This is done on Server with CentOS minimal installed, or server that you need to install packages on while pulling the packages from local reposotory you just added.
a) For Step 2 part 1:
b) For Step 2 part 2: : The IP address of the server I’m using is 192.168.1.60. Below is the repo configuration.
c) For Step 2 part 3: The mount point we used was /mnt/centos/cdrom/.
Check the repo added:
Then do yum clean all remove cached date and update repo list
NOTE: Enabling the repository locally added alone is not necessary enough to let us install software packages from it.This is because by default, any package being installed will use CentOS Base repository.We’ll discuss on a working solution to this shortly.
Package groups available in CentOS 7 repository are:
NOTE: When other CentOS repos are enabled and you specify centos-local repo, yum will always try to download latest package from repo with the latest package.The default repo being CentOS Base repo.
If you want to force yum to use local repository, you have to disable all other repos and enable them once you are done.You have two options you can use to achieve this.
Option 1: The simplest solution can be like below:
Then add add local repo.Do something like:
Check to see if successfully added:
You can do any installation.The only repo that yum will use is centos7-local. Examples:
- To install LDAP Service to configure OpenLDAP server:
As you you can see from below screenshot, the repository used is centos7-local.
- To install all packages belonging to “GNOME Desktop” Environment Group, we’ll do:
- To install single package like mariadb,mariadb-server, we’ll do:
Option 2: Using –enablerepo=centos7-local command option and –disablerepo=* command option,
To install all packages belonging to “Virtualization Host” Environment Group, we’ll do:
To install openldap
If you had CentOS 7 Minimal version and installed GNOME Desktop Environment Group packages, don’t forget to tell systemd to boot to GNOME Desktop Automatically.
Later on you can return the repos to original directory:
That’s all. Remember to copy repositories back from ~/repos/ to /etc/yum.repos.d/ directory.