1. Home
  2. General
  3. How do I create a RHEL or BCM repository for my organization?

How do I create a RHEL or BCM repository for my organization?

Purpose

In certain cases, a BCM cluster cannot access the internet directly. In these cases, having a local repository within the customer’s intranet is beneficial (e.g., in the case where a site is hosting multiple clusters, or in an airgapped environment. This KB article will describe creating a local repository using the BCM headnode’s web server.

These instructions can also be used if the local repository needs to be created on a non-BCM headnode, provided that yum/dnf have been installed, and the remote repositories have been correctly configured. Alternatively, the RPMs can be obtained from a DVD or ISO image.

Steps

Creating the Local Repository Folder

  1. On the BCM head node, navigate to /var/www/html
    # cd /var/www/html
  2. Create a repository directory “repos”,  and  navigate into the directory:
    # mkdir repos && cd repos

Adding Content to the Local Repository

There are several ways to add RPMs. You can copy them directly from a BCM ISO or use reposync, a utility that creates a local copy of an online RPM repository. 

Using a BCM ISO

  1. Mount the ISO locally on the head node:
    # mount -o loop,ro <ISO image> /mnt/iso
  2. Copy the contents of the ISO file into the repos directory created previously:
    # cp -r /mnt/iso/path/to/rpm/rectory /var/www/html/repos

Using reposync

  1. Install reposync, which is part of the yum-utils package:
    # yum install yum-utils
  2. Obtain the list of repositories by running yum repolist, for example:
    # yum repolist
    repo id repo name
    appstream Rocky Linux 9 - AppStream
    baseos Rocky Linux 9 - BaseOS
    cm-rhel9-trunk CM trunk for Red Hat Enterprise Linux 9
    crb Rocky Linux 9 - CRB
    cuda-rhel9-x86_64 cuda-rhel9-x86_64
    epel epel
    extras Rocky Linux 9 - Extras
  3. Provided that the YUM repositories are properly configured on the headnode, the following script (reposync.sh can be used):
    #!/bin/bash 

    ## declare an array variable

    declare -a arr=("appstream", "baseos", "cm-rhel9-trunk", "crb", "cuda-rhel9-x86_64", "epel", "extras")

    ## now loop through the above array

    for i in "${arr[@]}"
    do cd /var/www/html/repos mkdir -p $i
    reposync --gpgcheck -l --repoid=$i -n
    cd /home/rhel/$i
    createrepo -v /var/www/html/repos/$i
    done
  4. The -n flag at the end of the reposync command instructs reposync to download only the latest version of each RPM available on the remote repository. You can add or remove repositories from the array variable as needed.
  5. Make the reposync.sh script executable:
    # chmod +x reposync.sh
  6. Run the reposync script:
    # ./reposync.sh
  7. To use the newly created local YUM repository, first move (backup) all existing repo files:

    On the head node: 
    # cp -r /etc/yum.repos.d/ /root/yum.repos.d.bak
    In the software image:
    # cp -r /cm/shared/<software image>/etc/yum.repos.d /cm/shared/<software image>/root/yum.repos.d.bak
  8. Then remove the existing .repo files:
    On the head node: 
    # rm -f /etc/yum.repos.d/*
    In the software image:
    # rm -f /cm/shared/<software image>/etc/yum.repos.d/*
  9. Finally, create a .repo configuration file in /etc/yum.repos.d  for the headnodes, and /cm/shared/<software image>/etc/yum.repos.d for the software images. For example:
    [root@kerndev ~]# cat local-yum-repo.repo
    [appstream]
    name=My Rocky appstream $releasever - $basearch
    baseurl=http://<hostname of head node>/repos/appstream
    enabled=1
    gpgcheck=0

    [baseos]
    name=My Rocky baseos $releasever - $basearch
    baseurl=http://<hostname of head node>/repos/baseos
    enabled=1
    gpgcheck=0

    [cm-rhel9-trunk]
    name=My BCM RHEL9 Trunk
    baseurl=http://<hostname of head node>/repos/cm-rhel9-trunk
    enabled=1
    gpgcheck=0

    [crb]
    name=My crb packages
    baseurl=http://<hostname of head node>/repos/crb
    enabled=1
    pgpgcheck=0

    [cuda-rhel9-x86_64]
    name=My cuda packages
    baseurl=http://<hostname of head node>/repos/cuda-rhel9-x86_64
    enabled=1
    pgpgcheck=0

    [epel]
    name=My epel packages
    baseurl=http://<hostname of head node>/repos/baseos
    enabled=1
    pgpgcheck=

    [extras]
    name=My Rocky extras $releasever - $basearch
    baseurl=http://<hostname of head node>/repos/extras
    enabled=1
    pgpgcheck=0

Errata

  1. If the repositories need to reside outside of /var/www/html (for example, if the /var partition is too small) , you can move the repos directory to another location (in this example /home/repos), and then create an alias directory in the web server’s configuration  vim /etc/httpd/conf.d/local-repo.conf  and 
    Alias /repos /home/repos
    <Directory /home/repos>
    Options Indexes MultiViews FollowSymLinks
    Order allow,deny
    Allow from all
    </Directory>
  2. Afterward, restart the web server service on the head node: 
    # systemctl restart httpd
Updated on August 20, 2025

Related Articles

Leave a Comment