
videocam_off
This livestream is currently offline
Check back later when the stream goes live
In today’s video, I will walk you through **how to set up a Local APT Repository Server on Ubuntu 24.04** using `apt-mirror`.
If you manage multiple Ubuntu systems, creating a local APT mirror helps you:
✔ Download packages once and share across many machines
✔ Speed up updates and installations
✔ Save internet bandwidth
✔ Run updates in offline or isolated networks
---
## 🧰 **Prerequisites**
* Ubuntu 24.04 server
* At least **800GB** free space under `/var`
* Stable internet connection
👉 All commands and files used in this tutorial are shared below.
---
## 🛠️ **Steps Covered in This Tutorial**
Show More Show Less View Video Transcript
0:00
Hey everyone, welcome back to the
0:02
channel. In today's video, I'm going to
0:04
show you how to set up a local app
0:06
repository server on Ubuntu 24.04 using
0:09
App Mirror. If you manage multiple
0:11
Ubuntu machines like servers or desktop,
0:14
building a local app repository mirror
0:16
can save you time, bandwidth and give
0:18
you control over the package versions.
0:20
Why we need local app repository? There
0:22
are multiple reasons for that. First one
0:24
is single download for many machines.
0:27
Instead of letting many machines pull
0:30
package individually from the internet,
0:32
you download once on a central server.
0:34
Second one is faster installs and
0:36
updates. Local network transfers are
0:39
much faster than the internet downloads,
0:41
especially in the environment with many
0:43
systems. Third one, bandwidth saving.
0:46
Great for the networks with limited or
0:48
metered internet or to avoid saturating
0:51
bandwidth when many machines update at
0:53
once. The last one is work offline or
0:56
isolated networks. Ideal for air gap
0:59
labs, data centers or secure networks
1:02
without direct internet access. What do
1:04
you need before we start? You need a
1:07
dedicated Ubuntu 24.04 machine.
1:10
Sufficient free disk space on/war file
1:13
system minimum of 800 GB disk space.
1:16
Stable and relatively fast internet
1:19
connection. Whatever the commands and
1:21
files that I will use in this video
1:23
tutorial, I will share them in the
1:25
description for your reference. Let's
1:28
get started. As you can see, I have
1:30
already taken the SS session of my
1:32
Ubuntu 24.04 system where I will
1:35
configure this app repository server
1:37
using app mirror. First step is to
1:39
install the required packages like apt
1:42
mirror and apache 2. Run the following
1:44
app command.
1:59
This command will install the apt mirror
2:01
package and apache 2. As you can see in
2:03
the output, this apt mirror and Apache 2
2:05
package is already installed on my
2:07
system. Next, configure app mirror. Once
2:10
the app to mirror package is installed,
2:12
we will have its configuration file with
2:15
the name mirror-en list under /c/ app
2:20
folder.
2:24
This is the configuration file which apt
2:27
mirror command will use. Let's edit this
2:30
file and set the required parameters.
2:38
First replace this kinetic word with the
2:41
name noble. Noble is the code name for
2:43
Ubuntu 24.04.
2:51
Next unccomment these lines to set the
2:53
required variables.
3:05
This is the base path where all the
3:08
repositories will be mirrored and this
3:10
will be the mirror path. This will be
3:12
the skeleton for our repositories
3:15
structure and this will define all the
3:17
variables and this is the cleanup script
3:20
and we are downloading AMD uh 64 debin
3:23
packages or we are configuring in other
3:25
words we can say that we are mirroring
3:28
the AMD 64 repositories. This is post
3:31
mirror script. In addition to this we
3:34
need to add security updates repo URL.
3:37
So these lines shows that which
3:39
repositories to mirror. So for this
3:41
repository with the name noble these
3:45
components will be mirror under this
3:49
base path we need to add
3:58
in my system I don't have enough free
4:01
disk space to mirror this source
4:04
repositories as well so I am commenting
4:07
out these repositories in the cleanup
4:09
section I need to add one more script
4:12
which is required for this security
4:14
repository.
4:20
Save and close this file.
4:23
Next, start mirroring means downloading
4:26
packages locally. For that, we need to
4:29
run the command sudo
4:32
apt mirror. This command will start
4:36
fetching all the packages metadata and
4:38
the entire repository structure as
4:41
defined in the mirror list file. Since
4:43
this process can take several hours
4:45
depending upon the repository size,
4:47
enabled components and system
4:49
architecture, I would recommend run this
4:51
command using no hub so that it
4:53
continues to run even if the terminal
4:55
session disconnects or SS session
4:58
closes.
5:02
Hit enter and we can monitor the output
5:05
of this command using the command tail -
5:09
f and this file no hub out.
5:17
Once the mirroring is completed we'll
5:19
see the output something like this. This
5:21
confirms that mirroring is completed.
5:24
Let's close this.
5:27
Now serve the mirror via Apache web
5:30
server. For that we need to create the
5:32
symbolic links from the mirror
5:33
directories to the web root. Then the
5:36
command ln s.
5:54
As you can see in the output, this
5:56
mirror repositories path is soft link
6:00
with the web root of my Apache web
6:04
server. This URL is mapped to this
6:06
Ubuntu and the security URL is mapped to
6:11
Ubuntu security. Next, restart the
6:13
Apache web service in order to make
6:15
these changes into the fetch. With that,
6:17
you can run the command
6:20
sudo systemctl
6:23
restart
6:30
In order to test whether our uh
6:32
repository is accessible over the
6:34
browser or not, let's start the browser.
6:39
Type the URL
6:41
http
6:43
and then the IP address of your Ubuntu
6:46
system. In my case, it is 169144104.04/
6:54
Ubuntu/list
6:57
enter you would see the uh this page.
7:01
This confirms that our repository is
7:03
accessible over the browser. Now
7:05
automate our mirror sync with the
7:07
chrome. Let's create a job that will be
7:11
scheduled and that will do the daily
7:13
updates. Go to the CLI
7:17
and the command sudo chrome tab - e to
7:22
here
7:27
add this entry.
7:29
This job will execute every day on 2:00
7:34
a.m. in the morning and the logs of
7:36
these jobs will be stored under this log
7:40
file. Now save and close the file.
7:46
By scheduling this job, we make sure
7:48
that our mirror stays updated so that
7:51
the client always use fresh packages.
7:54
Next, configure the client machines to
7:56
use your local repository. I have
7:58
already taken the SS session of my
8:00
Ubuntu 24.04 client machine. App
8:03
repository configuration file is located
8:05
by default under the folder.
8:12
As you can see the content of this file
8:15
is moved to this new location. So edit
8:20
this file.
8:25
Replace this URL with our local
8:27
repository URL.
8:35
Save and close the file. First run sudo
8:39
apt update.
8:41
This will update your package index.
8:50
Let's try to install one of the sample
8:52
package. Let's say net hyphen tools.
9:00
Output confirms that net hyphen tools
9:03
has been installed using our local app
9:05
repository. That's it. You have
9:07
successfully set up a local app
9:09
repository server on Ubuntu 24.04.
9:13
If this tutorial helped you, like the
9:15
video, subscribe for more Linux and
9:17
DevOps tutorials. If you have any
9:19
questions, feel free to post it in the
9:21
comment section. Thanks for watching. I
9:23
will see you in the next one.
#Networking
#Software
