Overview
There have been plenty of times where I’ve had to install software onto a Red Hat-based server, like CentOS, that did not have a network connection to the Internet, or even the corporate network. This, of course, is problematic when you need to configure a web server or ftp server. You could download the binaries or source from the Internet and attempt an installation, which may require a lot of dependancies. Or you could move the server onto a network with Internet access, which cannot always be done.
The solution to this delima is to use your installation disc as a Yum repository. But how do you go about doing that? Follow along and I will show you how; it’s actually a very simplistic task to perform, consuming only minutes of your time.
Installing Packages From Media
CentOS comes with an existing Yum configuration file for using the installation disc or ISO as a repository. By default this repository is disabled, and for good reason. Before we can use it, we need to both mount the ISO somewhere and then enable the repository.
Mount ISO/DVD
Let’s start off by mounting our installation disc to the filesystem. We’re going to mount it to a new directory called CentOS in the /media directory.
- Create directory for mount.
mkdir /media/CentOS
- Load the DVD/ISO.
- Mount the disc image to the newly created directory.
mount /dev/cdrom /media/CentOS -t iso9600 -o loop
Enable the Yum Repository and Install Packages
Our disc is now mounted and now we need to enable the existing repository. This step will actually disable the Internet repositories and enable only the Media repository. For this to work, the disc must be mounted to the directory /media/CentOS.
- Enable Media repo and disable all others.
yum --disablerepo=* --enablerepo=c6-media
- Install packages from the disc to your server using yum as you normally would.
yum install package name
Disable the Yum Repository
After installing the packages, you may want to disable the media repository.
- Disable Media repo and enable all others.
yum --enablerepo=* --disablerepo=c6-media
- Alternatively, you can just disable all repositories.<
yum --disablerepo=*
Summary
As you can see, adding the installation disc as a repository is very simple. You now safely deploy and configure servers in your staging area or development area or any network where Internet access may not be allowed or is severely limited.
This approach is good for one-off or irregular deployments. If you find yourself needing to do this more frequently, you can also copy the contents of the installation disc to a share and create a new respository configuration file for it.