Daniele Raffo

A smooth sea never made a skillful mariner.

Install RHEL packages without network connection

I found myself in this situation while working as a Linux engineer. I needed to install a package Foobar on a RHEL 6 server which, for some reason, had no connection to the network. The package required a complex list of dependencies, so it was not possible to simply grab the RPM and upload it on the server. How would you proceed?

1. Set up a stub machine, by creating another Virtual Machine with a fresh install of the same RHEL version on it. Make sure you perform a minimal installation with the minimum numbe of packages required for the machine to run. Then run the following commands on the machine:

mkdir /root/tmppkg
yum --downloadonly --downloaddir=/root/tmppkg install foobar

Yum will download Foobar and all its dependencies recursively, storing the RPMs in the directory mentioned above.

2. Create a local repository from the bunch of packages downloaded by Yum:

chown -R root:root /root/tmppkg
createrepo /root/tmppkg
chmod -R 755 /root/tmppkg

3. Set up a local repository on the server. Transfer the tmppkg directory on the server (e.g. via an USB thumb drive) and put it in the /share directory. Then create a file /etc/yum.repos.d/local.repo as such:

[local]
name=Local repository
baseurl=file:///share/tmppkg
enabled=1
gpgcheck=0
protect=1

4. You can now install the Foobar package in the usual way:

yum install foobar

The package manager will fetch all the necessary content from the newly created local repository.
Once you’ve installed the package, the /share/tmppkg directory can be safely deleted:

rm -rf /share/tmppkg

You might ask yourself why you couldn’t simply make a copy of the whole repository from RHN and transfer it to the server, skipping altogether the first two steps. Unfortunately, this is not feasible as the whole repository is several Gb large, and therefore this would require a long transfer time and a large amount of free disk space on the server.



by Daniele Raffo         page created on 1 September 2015         page last changed on 15 November 2024