If you haven’t found yourself in this situation while working as a Linux sysadmin, you will — one day or the other.

You need to install a package (let’s call it Foobar) on a RHEL server which, for some reason, has no connection to the network. The package requires a complex list of dependencies, so it’s not simply a matter of grabbing the RPM and uploading it on the server. How do you proceed?

1. Set up a stub machine

First, create a Virtual Machine and do a fresh install of the same RHEL version on it. Make sure you perform a minimal installation so that the packages installed on the machine are kept to the minimum required for the machine to run.

Then run the following commands on the machine:

[vm]# mkdir /root/tmppkg
[vm]# 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

The second step is to create a repository from the bunch of packages downloaded by Yum.

[vm]# chown -R root:root /root/tmppkg
[vm]# createrepo /root/tmppkg
[vm]# chmod -R 755 /root/tmppkg

3. Set up the local repository on the server

Transfer the tmppkg directory on the server (via USB thumb drive or CD-ROM) 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

Now you can install the Foobar package on the server in the usual way. The package manager will fetch all the necessary content from the newly created local repository:

[server]# yum install foobar

Once you’ve installed the package, the /share/tmppkg directory can be safely deleted.

You might ask yourself why you couldn’t simply make a copy of the whole repo from RHN and transfer it to the server, hence skipping steps #1 and #2 altogether. The answer is that the whole repository makes several Gb in size, and therefore this solution would require a long transfer time and a large amount of free disk space on the server.

1 réponse
  1. Hebergement Solutions
    Hebergement Solutions dit :

    Merci d’avoir publier cette article! Je suis votre site depuis longtemps
    mais je n’avais jamais songé à laisser un commentaire.Je me suis inscrit à votre blog et j’ai partager votre
    article sur mon compte Twitter. Merci encore
    pour cet article! Il est très bien écrit et l’information est complète 🙂

    Répondre

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.