Using your DVD as a yum repository on a RPM based Linux

So, you’ve just gotten a fresh installed Linux system with Oracle Linux or Redhat Linux from the sysadmin. And with Oracle Linux you can not use the internet (forbidden by company laws is a common one), or you got Redhat Linux and can not use up2date for some reason. Most of the time, when installing Oracle products I am allowed to use the root account myself during the install. The DVD most of the time is still present in the drive.

You could mount the DVD and use ‘rpm’ directly to install packages off the DVD. If you get an error the rpm package has a dependency, you resolve the dependency, if that depended package has a dependency itself, you resolve that, etc. That’s something you could do. But there is an easier way!

Mounting the DVD

The first task is to mount the DVD again. The installation procedure does not add an entry in /etc/fstab to mount the DVD in an easy way, so I do that myself. The installer makes a generic device in /dev for the DVD, /dev/dvd, which is a symbolic link to the device that truly is the DVD drive. This is how the line for /etc/fstab looks like:

/dev/dvd                /media                  udf,iso9660 noauto,user,ro              0 0

First column is the device, second column is the directory the device get mounted to, the third column are the filesystem types, the fourth column are the mount options (noauto: the DVD does not get mounted automatically, it needs to be mounted explicitly, user: a regular user is allowed to mount the device, ro: readonly).
Next we need to mount the dvd using the command:

mount /media

It will briefly wait before returning the cursor, during which it mounts the DVD to the /media directory, and can be checked by looking at all the mounts:

# mount
/dev/mapper/vg00-lvroot on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/cciss/c0d0p1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sr0 on /media type iso9660 (ro,noexec,nosuid,nodev)

Setup the repository information

Okay, now that we have the DVD mounted, let’s create a DVD based yum repository. The repositories are listed in the directory /etc/yum.repos.d. Repositories can be grouped in files. A default installed system lists a few repositories:

# ls /etc/yum.repos.d
redhat.repo  rhel-debuginfo.repo  rhel-source.repo

Redhat.repo does not contain any repository (the remarks in the file suggest that a subscription manager probably will use this file), rhel-debuginfo.repo has two repositories in it with the debug-info packages (binaries with the debugging information in the binary, so you have all the debug information to get full information with for example gdb; normal binaries are ‘stripped’), rhel-source.repo contains a repository with all the source rpm’s in it. All these repositories are disabled (enabled=0).

To get yum use the DVD as a repository, add a file ‘rhel-dvd.repo’ in /etc/yum.repos.d with the following content:

name=Red Hat Enterprise Linux Installation DVD

The added repository is named ‘dvd’, and is disabled. In order to use this repository, add ‘–enablerepo=dvd’ to use it. This way it doesn’t interfere with anything, like someone adding a web-based (“real”) repository.

Using the repository

Now you can add packages, which dependencies are resolved by yum using:

# yum install --enablerepo=dvd packagename

just like when yum is setup with a “real” web-based repository.

Another extremely handy feature of yum is searching for a specific file in the repository. For example, if you want to send files as attachment on linux, one way of attaching files is using the ‘uuencode’ executable to generate a file as mail attachment. ‘uuencode’ is not installed by default, nor a package with that name exists. To search in the yum repository for a file called ‘uuencode’, enter the following:

# yum provides --enablerepo=dvd */uuencode
Loaded plugins: product-id, security, subscription-manager
Updating Red Hat repositories.
sharutils-4.6.1-2.x86_64 : The GNU shar utilities for packaging and unpackaging shell archives.
Repo        : dvd
Matched from:
Filename    : /usr/bin/uuencode

This shows the package ‘sharutils’ contains a file ‘/usr/bin/uuencode’.

  1. Nigel said:

    Fantastic way to do it. I was strugling to get it to work with the default mount by using \ to add spaces but this way is much better. Many Thanks

  2. Kath Po said:

    You may be interested in correcting lines where accidentally appeared.
    # ls /etc/yum.repos.d ..

  3. Svani said:

    Helpful, Thanks.
    maybe you need this after:
    rpm –import file:///media/diskname/RPM-GPG-KEY-redhat-release

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: