Breaking News
Loading...
Saturday, July 20, 2013

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

8:45 PM

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
    

0 comments:

Post a Comment

 
Toggle Footer