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

Share this Article :

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 :

    [[email protected] ~]# 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:

    [[email protected] ~]# 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 :

    [[email protected] ~]# yum install httpd -y
    

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

    [[email protected] ~]# 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 :

    [[email protected] ~]# mkdir /mnt/localrepo
    

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

    [[email protected] ~]# mkdir -p /mnt/localrepo/{1,2,3}
    

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

    [[email protected] ~]# mount -o loop /dev/cdrom /mnt/localrepo/1
    
    [[email protected] ~]# 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.

    [[email protected] ~]# mkdir /tmp/repo
    

6. Copy the require pacckages to install create repo:

    [[email protected] ~]# cp /mnt/localrepo/1/Packages/createrepo* /tmp/repo
    [[email protected] ~]# cp /mnt/localrepo/1/Packages/deltarpm* /tmp/repo
    [[email protected] ~]# cp /mnt/localrepo/1/Packages/libxml2-python* /tmp/repo
    [[email protected] ~]# cp /mnt/localrepo/1/Packages/python-deltarpm* /tmp/repo
    [[email protected] ~]# 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:

    [[email protected] ~]# 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.

    [[email protected] ~]# cd /mnt/localrepo/
    

9. Run createrepo command :

    [[email protected] 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
    [[email protected] localrepo]# ls
    1  2  3  repodata
    

10. Clean up the repo :

    [[email protected] ~]# 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 :

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


No Responses

Leave a Reply