Chapter #29: Setting Up a Network Repository on Ubuntu
Learn how to set up a local or network-based Ubuntu 24.04 repository using the DVD ISO for offline package management.

Installing, updating, and removing packages are core responsibilities of a system administrator. On Ubuntu, this is usually done with apt
or dpkg
for .deb
files.
However, when a machine is offline, we need alternative methods, which could be to save Internet bandwidth, compile packages locally, or follow legal rules for some software, and this is where a network repository becomes useful.
In this chapter, weβll set up an Ubuntu 24.04 server as a repository (IP: 192.168.0.18
) and a client machine that uses it.
Install and Configure the Repository Server
Weβll serve the repository over HTTP, which allows clients to access packages and browse them in a web browser.
sudo apt update
sudo apt install apache2
sudo systemctl enable --now apache2
Next, create directories to store .deb
packages, organizing them by Ubuntu version and architecture.
sudo mkdir -p /var/www/html/repos/ubuntu/24.04/{main,universe,restricted,multiverse}
Add .deb
Packages to the Repository
After creating the repository directories, you need to populate them with .deb
packages, which are the actual software packages that your clients will install.
The easiest source for this is the Ubuntu DVD ISO, which contains a comprehensive set of packages for the release.
Download Ubuntu DVD ISO
Download the Ubuntu 24.04 DVD ISO from the official Ubuntu releases page, which contains the pool
directory, which holds all .deb
packages for the main
, universe
, and other components.
Mount Ubuntu DVD ISO
Mount the ISO to a temporary mount point so its contents can be accessed by the filesystem:
sudo mkdir -p /mnt/ubuntu-dvd
sudo mount -o loop ~/Downloads/ubuntu-24.04-dvd.iso /mnt/ubuntu-dvd
-o loop
tells the system to treat the ISO file as a block device./mnt/ubuntu-dvd
becomes the accessible root directory of the ISO contents.
Copy .deb
Packages to Repository Directories
Copy the .deb
files from the ISO into the repository directories you created:
# Core (main) packages
sudo cp /mnt/ubuntu-dvd/pool/main/*/*.deb /var/www/html/repos/ubuntu/24.04/main/
# Optional universe packages
sudo cp /mnt/ubuntu-dvd/pool/universe/*/*.deb /var/www/html/repos/ubuntu/24.04/universe/
Notes:
- The ISO organizes packages under
pool/<component>/<package>/
. The glob pattern*/*.deb
ensures that all.deb
files in the subdirectories are included. - Maintaining the separation between
main
,universe
, and other components are recommended to reflect the Ubuntu repository structure and simplify client configuration.
Generate the Repository Metadata
APT requires a Packages index file to locate and resolve dependencies for the .deb
files. Use dpkg-scanpackages
to generate this metadata:
cd /var/www/html/repos/ubuntu/24.04/main
sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
cd /var/www/html/repos/ubuntu/24.04/universe
sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
- The
dpkg-scanpackages
command recursively scans the directory for.deb
files and creates a Packages file with package metadata (name, version, architecture, dependencies, etc.). gzip -9c > Packages.gz
compresses the index for efficient access by APT clients.- Repeat this for each component (
main
,universe
,multiverse
, etc.) that you include in your repository.
After this step, your repository is fully populated and ready to be served over HTTP to client systems.
Configure the Ubuntu Client
To make the locally hosted repository available to an Ubuntu client, you must register it with the APT package manager, which involves creating a repository configuration file under /etc/apt/sources.list.d/
.