How to Setup Local Yum Repository from CD-ROM/DVD-ROM image on CentOS 6.2

In this post, i will share on how to update and install the RPM packages from CD-ROM/DVD-ROM image on CentOS 6.2. This will very useful when you are running on slow internet connection. Instead of go through the internet connection, it is possible to use Local CD/DVD-ROM as your yum repository. There are two methods to install and configure local CentOS 6.2 yum repository. Both methods have been tested and working on CentOS 6.2 linux server. You can select any method that you most preferred. This may be also applicable on other version of CentOS server.

Method 1:
1. Insert DVD/ISO into DVD-Drive.
2. Mount the ISO from the DVD-ROM into /mnt directory :

    [root@centos62 ~]# mount /dev/cdrom /mnt
    mount: block device /dev/sr0 is write-protected, mounting read-only
    

3. Create centos62.repo text file in /etc/yum.repos.d/ with the following content. Please create something as follow:

    [root@centos62 ~]# vi /etc/yum.repos.d/centos62.repo
    
    [CentOS6.2-Repository]
    name=DVD-CentOS6.2 repository
    baseurl=file:///mnt
    enabled=1
    gpgcheck=0
    

4. Finish. You can start install, remove and update using yum command :
Example :

    [root@centos62 ~]# yum install httpd -y
    

Method 2 :
1. Check the existing partition on your CentOS 6.2 server

    [root@centos6 ~]# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                          18102140   1165764  16016824   7% /
    tmpfs                   515444         0    515444   0% /dev/shm
    /dev/sda1               495844     29842    440402   7% /boot
    

2. Create localrepo directory in /mnt :

    [root@centos6 ~]# mkdir /mnt/localrepo
    

3. Create 1 2 3 directory in /mnt/localrepo

    [root@centos6 ~]# mkdir -p /mnt/localrepo/{1,2,3}
    

4. Mount the ISO from the DVDROM into /mnt/localrepo/1 directory

    [root@centos6 ~]# mount -o loop /dev/cdrom /mnt/localrepo/1
    
    [root@centos6 ~]# df -lh
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           18G  1.2G   16G   7% /
    tmpfs                 504M     0  504M   0% /dev/shm
    /dev/sda1             485M   30M  431M   7% /boot
    /dev/sr0              3.6G  3.6G     0 100% /mnt/localrepo/1
    

5. Create Temporary repo folder under /tmp to put required rpm’s packages for createrepo installation.

    [root@centos6 ~]# mkdir /tmp/repo
    

6. Copy the require pacckages to install create repo:

    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/createrepo* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/deltarpm* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/libxml2-python* /tmp/repo
    [root@centos6 ~]# cp /mnt/localrepo/1/Packages/python-deltarpm* /tmp/repo
    [root@centos6 ~]# ls /tmp/repo
    createrepo-0.9.8-4.el6.noarch.rpm          libxml2-python-2.7.6-4.el6.i686.rpm
    deltarpm-3.5-0.5.20090913git.el6.i686.rpm  python-deltarpm-3.5-0.5.20090913git.el6.i686.rpm
    

7. Install the rpm packages using below command:

    [root@centos6 ~]# rpm -ivh /tmp/repo/*
    Preparing...                ########################################### [100%]
       1:deltarpm               ########################################### [ 25%]
       2:python-deltarpm        ########################################### [ 50%]
       3:libxml2-python         ########################################### [ 75%]
       4:createrepo             ########################################### [100%]
    

8. Go to /mnt/localrepo directory.

    [root@centos6 ~]# cd /mnt/localrepo/
    

9. Run createrepo command :

    [root@centos6 localrepo]# createrepo .
    2704/3042 - 1/Packages/system-config-users-docs-1.0.8-1.el6.noarch.rpm
    iso-8859-1 encoding on Ville Skyttä  - 2.8.2-2
    
    3042/3042 - 1/Packages/zsh-4.3.10-4.1.el6.i686.rpm
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    [root@centos6 localrepo]# ls
    1  2  3  repodata
    

10. Clean up the repo :

    [root@centos6 ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning up Everything
    Cleaning up list of fastest mirrors
    

11. Create a repo config file in /etc/yum.repos.d/ directory :

    [root@centos6 ~]# vi /etc/yum.repos.d/local.repo
    
    [CentOS6.2-Repository]
    name=CentOS6.2 repository
    baseurl=file:///mnt/localrepo
    enabled=1
    gpgcheck=0
    

How to Reset the Directory Manager Password on RHEL 7 / CentOS 7
How to Reset the Directory Manager Password on RHEL 7 / CentOS 7

It is best practice to remember passwords, but because too many passwords, sometimes we forget. We are not encouraged to write the password on any paper or share the password...

How to Find Big Files Size on Linux RHEL/CentOS
How to Find Big Files Size on Linux RHEL/CentOS

As the linux administrator, sometimes we have to identify which files are most take much space in the linux server resulting in low free space. Low disk space can also...

Why Linux users should worry about malware and what they can do about it
Why Linux users should worry about malware and what they can do about it

Don’t drop your guard just because you’re running Linux. Preventing the spread of malware and/or dealing with the consequences of infection are a fact of life when using computers. If...

How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7
How to Reset Forgotten Root Password on Linux RHEL 7 / CentOS 7

This short howto will explain the steps to reset a lost root password or to reset a forgotten root password on Linux RHEL 7 or CentOS 7. Basically, we will...

How to Update CentOS or Upgrade CentOS to the Latest Version
How to Update CentOS or Upgrade CentOS to the Latest Version

Recently, the latest version of CentOS 7.3 was released. All users of CentOS 7.0, 7.1 and 7.2 can upgrade their system to the most recent. This quick guide will explain...

How to Change your WordPress Username, Nickname and Display Name in MySQL
How to Change your WordPress Username, Nickname and Display Name in MySQL

After you create an account log in WordPress, you may want to change your WordPress username, as appropriate or due to security reason. However, you can not do this from...

How to Enable SSH Root Login on Ubuntu 16.04
How to Enable SSH Root Login on Ubuntu 16.04

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that...

How to Change UUID of Linux Partition on CentOS 7
How to Change UUID of Linux Partition on CentOS 7

UUID (Universally Unique IDentifier) should be unique and it is used to identify storage devices on a linux system. If you cloned a virtual machine from vCenter, the metadata containing...

1 Trackback or Pingback

Leave a Reply

Your email address will not be published. Required fields are marked *