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

How do I create a Ubuntu repository for my organization?

Purpose

In certain cases, the cluster cannot access the Internet directly, or having a local repository within the company intranet may be beneficial, e.g., when a site is hosting multiple clusters. This KB article will describe how to create a local repository using the head node’s web server when running Ubuntu. The same steps will work for Ubuntu servers in general if you want to host a repository on a third-party server.

Steps

Make packages available

The first step is to create a directory under /var/www/html/ which contains the packages you want to make available. This will use the existing head node web server to provide the files. For example, create /var/www/html/repos:

# mkdir /var/www/html/repos

We now need to put packages into this directory. Two common ways to obtain packages are to copy the installer ISO packages or mirror a remote repository.

Option 1: Copy ISO Packages

To copy the installer ISO packages, mount a copy of the installer ISO locally and copy the packages to the newly created directory. For example:

# mkdir /mnt/iso
# mount bcm-10.0-ubuntu2204.iso /mnt/iso
# cp -r /mnt/iso/data/packages/ /var/www/html/repos/

NOTE: This will copy all the ISO packages to your local head node repository. You can specify a direct path to only copy certain architectures or packages as desired instead of the broader /mnt/iso/data/packages, e.g., /mnt/iso/data/packages/dist/ubuntu/2204/.

Option 2: Mirror a Remote Repository

To mirror a remote repository, apt-mirror is a suggested (but not officially endorsed) tool. You can install apt-mirror via the apt package manager.

# apt update; apt install apt-mirror -y

After installation, modify the /etc/apt/mirror.list file and configure it as desired.

NOTE: A minimum suggested configuration is to uncomment the “set base_path” configuration option and specify a path where you want the mirrored repository to be downloaded. Review the list of repository entries to include those you want to mirror.

Once you are satisfied with the configuration, you can run apt-mirror to begin mirroring the remote repositories. You may want to run this in a screen or tmux session, as there may be a lengthy package download.

# apt-mirror

Create Packages.gz file

Depending on how you copied your packages and the source, your repository will also need a Packages.gz file. This command will change to the newly created directory, scan all packages, and make a compressed Packages file:

# cd /var/www/html/repos; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

NOTE: Some paths in the ISO have an existing Packages.gz that can be used as shown in the section below, “Add the Repo to Clients”.

At this point, the newly created repository is functional.

Add Repo to Clients

You can now add the repository to /etc/apt/sources.list on systems where you want to use the new repository.

Add the following to the sources.list file.

NOTE: The IP 10.141.255.254 should change to the DNS name or IP of the server that will be reachable by the server you are adding the repository to. You will need to run apt update afterwards.

# echo "deb [trusted=yes] http://10.141.255.254/repos/ ./" >> /etc/apt/sources.list
# apt update

To use your new repository in software images, connect to the software image chroot with the command cm-chroot-sw-img :

# cm-chroot-sw-img /cm/images/<image name>

Afterward, modify /etc/apt/sources.list to include the new repository.

NOTE: Again, the 10.141.255.254 IP should be changed to the repository server’s DNS name or IP. After adding the new repository, you will need to run apt update.

# echo "deb [trusted=yes] http://10.141.255.254/repos/ ./" >> /etc/apt/sources.list
# apt update

NOTE: The source format expects a Packages.gz file to exist at the path specified. Some paths from the ISO already include a Packages.gz that can be used if desired, for example:

deb [trusted=yes] http://10.141.255.254/repos/packages/dist/ubuntu/2204/ ./
deb [trusted=yes] http://10.141.255.254/repos/packages/10.24.07/ubuntu/2204/ ./
deb [trusted=yes] http://10.141.255.254/repos/packages/packagegroups/hpc ./

You should now be able to use your new repository to install packages.

Updated on September 8, 2025

Related Articles