Monday, December 1, 2014

Using your Oracle Linux ISO as local YUM Repository

If you don't have an Internet connection on your server and you want to install some packages through yum, then there is a very interesting workaround for that: you can use your CD/DVD or ISO-file as local YUM repository.

In this blog post, I will explain to you how you can configure it.  Here I will use a virtualized environment that uses an ISO-file.

(1)
In your VM environment, attach the CD/DVD-iso to your Linux VM.
This operation will mount automatically the ISO in the /media directory.

(2)
Unmount (not eject) the ISO through the GUI or commandline:
[root@ol6 ~]# umount /media/OL6.5\ x86_64\ Disc\ 1\ 20131125/

(3)
Create a directory where we will mount this ISO:
[root@ol6 ~]# mkdir /OL6DVD
[root@ol6 ~]# mount /dev/sr0 /OL6DVD/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@ol6 ~]# ls /OL6DVD/
EFI         GPL               LoadBalancer  README-en.html           RELEASE-NOTES-x86_64-en.html  ResilientStorage    Server
EULA        HighAvailability  media.repo    RELEASE-NOTES-en         RELEASE-NOTES-x86-en          RPM-GPG-KEY         supportinfo
eula.en_US  images            Packages      RELEASE-NOTES-en.html    RELEASE-NOTES-x86-en.html     RPM-GPG-KEY-oracle  TRANS.TBL
eula.py     isolinux          README-en     RELEASE-NOTES-x86_64-en  repodata                      ScalableFileSystem  UEK3
[root@ol6 ~]# mount | grep OL6
/dev/sr0 on /OL6DVD type iso9660 (ro)

(4)
Create a config file to use this local repo:
[root@ol6 ~]# more /etc/yum.repos.d/local.repo
[local]
name=OL6u5 DVD Repository
baseurl=file:///OL6DVD

(5)
The keys must be imported from this local repo:
[root@ol6 ~]# rpm --import /OL6DVD/RPM-GPG-KEY
[root@ol6 ~]# rpm --import /OL6DVD/RPM-GPG-KEY-oracle

(6)
Verify that you use this local repo:
[root@ol6 ~]# yum repolist
Loaded plugins: refresh-packagekit, security
local                                                                                                                                   | 3.7 kB     00:00 ...
local/primary_db                                                                                                                        | 3.0 MB     00:00 ...
http://public-yum.oracle.com/repo/OracleLinux/OL6/UEKR3/latest/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'public-yum.oracle.com'"
Trying other mirror.
repo id                                            repo name                                                                                             status
local                                              OL6u5 DVD Repository                                                                                  3,669
public_ol6_UEKR3_latest                            Unbreakable Enterprise Kernel Release 3 for Oracle Linux 6Server (x86_64)                                 0
public_ol6_latest                                  Oracle Linux 6Server Latest (x86_64)                                                                      0
repolist: 3,669

(7)
In the existing public config file (“/etc/yum.repos.d/public-yum-ol6.repo”) disable all repo sources by setting the enabled parameter on “0”.
Verify again the used yum repo:
[root@ol6 ~]# yum repolist
Loaded plugins: refresh-packagekit, security
repo id                                                               repo name                                                                          status
local                                                                 OL6u5 DVD Repository                                                               3,669
repolist: 3,669

(8)
We can now install packages through the local yum repo.
Verify that the package “lsscsi” does not exist yet on the system.
Install the package through the local yum repo:
[root@ol6 ~]# yum install lsscsi
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lsscsi.x86_64 0:0.23-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
 Package                              Arch                                 Version                                   Repository                           Size
===============================================================================================================================================================
Installing:
 lsscsi                               x86_64                               0.23-2.el6                                local                                38 k

Transaction Summary
===============================================================================================================================================================
Install       1 Package(s)

Total download size: 38 k
Installed size: 75 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lsscsi-0.23-2.el6.x86_64                                                                                                                    1/1
  Verifying  : lsscsi-0.23-2.el6.x86_64                                                                                                                    1/1

Installed:
  lsscsi.x86_64 0:0.23-2.el6

Complete!

(9)
Verify the package info:
[root@ol6 ~]# yum info lsscsi
Loaded plugins: refresh-packagekit, security
Installed Packages
Name        : lsscsi
Arch        : x86_64
Version     : 0.23
Release     : 2.el6
Size        : 75 k
Repo        : installed
From repo   : local
Summary     : List SCSI devices (or hosts) and associated information
URL         : http://sg.danny.cz/scsi/lsscsi.html
License     : GPLv2+
Description : Uses information provided by the sysfs pseudo file system in Linux kernel
            : 2.6 series to list SCSI devices or all SCSI hosts. Includes a "classic"
            : option to mimic the output of "cat /proc/scsi/scsi" that has been widely
            : used prior to the lk 2.6 series.
            :
            : Author:
            : --------
            :     Doug Gilbert <dgilbert(at)interlog(dot)com>


No comments:

Post a Comment