Running updates across a fleet of Ubuntu servers can turn into a slow, repetitive chore. Every machine downloads the same packages from the internet, saturating your WAN link, and a slow or flaky upstream mirror can stall an entire maintenance window. A local apt mirror ubuntu setup solves this cleanly: one server downloads packages once, and every other machine on your network pulls them from your LAN at full local speed.

In this guide, you will install apt-mirror on Ubuntu 24.04, configure it to mirror the Noble Numbat repositories, schedule automatic syncs, serve the mirror over HTTP, and point your client servers at it. By the end, your fleet will update faster, use far less internet bandwidth, and keep working even when the public archive is slow or unreachable.
Prerequisites
Before you start, make sure you have the following in place:
- A dedicated Ubuntu 24.04 server to act as the mirror host. A virtual machine works well.
- At least 250 GB of free disk space for the full Noble main, restricted, universe, and multiverse archives (amd64, binary packages only). Add more if you also mirror source packages.
- A static IP address or stable hostname for the mirror server, reachable from every client.
- A web server (Nginx or Apache) installed on the mirror host, or willingness to install one during this guide.
- Root or sudo access on both the mirror host and the clients.
- One or more Ubuntu 24.04 clients to test against.
A full mirror is an investment in disk space, but it pays for itself quickly on any network with more than a handful of servers. If disk space is tight, consider mirroring only the components you actually use, for example main and restricted, and skip the source packages entirely. Plan the host as permanent infrastructure: a well-kept local apt mirror ubuntu host earns its keep on every update cycle.
Step 1: Install apt-mirror
apt-mirror is available in the Ubuntu universe repository. Update your package index and install it:
sudo apt update
sudo apt install apt-mirror
On a fresh Ubuntu 24.04 install, the universe repository is usually enabled by default. If the package is not found, enable universe first and update again:
sudo add-apt-repository universe
sudo apt update
sudo apt install apt-mirror
The package installs the apt-mirror binary and a default configuration file at /etc/apt/mirror.list. It does not start syncing anything until you configure and run it.
Step 2: Configure the Local APT Mirror Ubuntu Repositories
Open /etc/apt/mirror.list in your editor. The stock file contains commented examples for older releases; replace its contents with a configuration for Ubuntu 24.04 (Noble Numbat). A solid starting point for a local apt mirror ubuntu deployment looks like this:
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch amd64
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
What each part does:
- base_path (default
/var/spool/apt-mirror) is where all mirrored data lives. Point it at your large disk or mount if needed. - defaultarch amd64 limits the mirror to 64-bit packages. Add
arm64lines only if you run ARM machines. - nthreads 20 downloads up to 20 files in parallel, which greatly speeds up the initial sync.
- deb lines list the repositories to mirror: the base release, updates, security updates, and backports, each with all four components.
- clean lines tell apt-mirror which upstream hosts it may prune. Without them, obsolete package files accumulate forever.
If you want source packages as well, add matching deb-src lines. Be aware that source packages roughly double the disk usage, and most fleets never need them.
Save the file and check that the base path has enough room:
df -h /var/spool/apt-mirror
Step 3: Run the First Sync
The initial sync downloads tens of gigabytes, so start it in a persistent session such as tmux or screen, or run it in the background with nohup. Run:
sudo apt-mirror /etc/apt/mirror.list
apt-mirror prints progress as it fetches package indexes and then the package files themselves. The first run can take anywhere from under an hour on a fast connection to several hours on a slow one. Subsequent runs are incremental and download only new or changed packages, so your local apt mirror ubuntu store stays current at low cost.
When the run finishes, verify the directory layout:
ls /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/dists/
sudo du -sh /var/spool/apt-mirror
You should see noble, noble-updates, noble-security, and noble-backports under dists/, and a growing pool/ directory containing the actual .deb files.
Step 4: Schedule Automatic Syncs with Cron
A local apt mirror ubuntu host that never syncs is worse than no mirror, because clients would install stale packages. Schedule a daily sync in the early hours. Create a cron file:
sudo nano /etc/cron.d/apt-mirror
Add this line to sync every night at 02:00:
0 2 * * * root /usr/bin/apt-mirror /etc/apt/mirror.list > /var/spool/apt-mirror/var/cron.log 2>&1
The log file lets you confirm each run completed. Check it after the first scheduled run:
tail -n 50 /var/spool/apt-mirror/var/cron.log
If your upstream bandwidth is limited, syncing once a day is a good balance. Security updates land in noble-security quickly, so do not stretch the interval beyond 24 hours on production fleets.
Step 5: Serve the Mirror Over HTTP
Clients fetch packages over HTTP, so expose the mirrored tree with your web server. With Nginx, create a site that serves the mirror directory. The mirrored Ubuntu tree lives at /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu, so point a location at its parent:
sudo nano /etc/nginx/sites-available/apt-mirror
server {
listen 80;
server_name mirror.example.lan;
location /ubuntu/ {
alias /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/;
autoindex on;
}
}
Enable the site and reload Nginx:
sudo ln -s /etc/nginx/sites-available/apt-mirror /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
Replace mirror.example.lan with your mirror server’s hostname or IP address. If you use Apache instead, an equivalent Alias directive in a virtual host achieves the same result. Test from the mirror host itself:
curl -s http://localhost/ubuntu/dists/noble/Release | head -n 5
You should see the Release file contents. If you get a 404, check the alias path and trailing slashes: with Nginx alias, the trailing slash on both the location and the path matters. Once the Release file loads, your local apt mirror ubuntu installation is ready for clients.
Step 6: Point Clients at Your Local APT Mirror Ubuntu Server
Pointing a client at your local apt mirror ubuntu server takes only a few minutes. On each Ubuntu 24.04 client, back up the existing sources and replace the archive URL with your mirror. Ubuntu 24.04 uses the DEB822-style file /etc/apt/sources.list.d/ubuntu.sources by default. Back it up first:
sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
Then edit the file and change every URIs: line from http://archive.ubuntu.com/ubuntu to your mirror, for example:
URIs: http://192.168.1.10/ubuntu
If a client still uses the classic one-line format in /etc/apt/sources.list, the equivalent entry is:
deb http://192.168.1.10/ubuntu noble main restricted universe multiverse
deb http://192.168.1.10/ubuntu noble-updates main restricted universe multiverse
deb http://192.168.1.10/ubuntu noble-security main restricted universe multiverse
deb http://192.168.1.10/ubuntu noble-backports main restricted universe multiverse
Replace 192.168.1.10 with your mirror server’s IP or hostname. Then update and test on the client:
sudo apt update
sudo apt install --dry-run htop
If apt update completes without errors and shows your mirror host in its output, the client is using your local mirror. For larger fleets, automate this change with Ansible or a configuration management tool rather than editing each machine by hand.
Keeping clients current is only half of good fleet hygiene. Once your mirror is running, consider pairing it with automatic security updates on Ubuntu so patches apply promptly, and review how to disable SSH password login on Ubuntu 24.04 to harden the same servers.
Verification
These checks confirm your local apt mirror ubuntu deployment works end to end before you roll it out to production machines:
- Mirror content:
ls /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu/dists/noble/shows Release files and component directories. - HTTP serving: browsing
http://192.168.1.10/ubuntu/dists/noble/Releasefrom a client returns the Release file. - Client updates:
sudo apt updateon a client succeeds and fetches from your local apt mirror ubuntu host, not archive.ubuntu.com. - Install test: installing a package that was not previously cached on the client, such as
htop, downloads from the mirror at LAN speed. - Cron sync: the cron log shows a completed run after the next scheduled sync.
For an extra check, watch bandwidth during a client update: traffic should stay on your LAN instead of saturating the internet connection.
Troubleshooting
Most problems with a local apt mirror ubuntu setup fall into a few familiar categories:
apt-mirror fails with 404 errors
A 404 usually means a wrong distribution name or component. Double-check that the release is noble for Ubuntu 24.04 and that each component is spelled correctly: main, restricted, universe, multiverse. Also verify the upstream URL is reachable from the mirror host with curl -I http://archive.ubuntu.com/ubuntu/dists/noble/Release.
The mirror directory keeps growing
Make sure your clean http://archive.ubuntu.com/ubuntu line is present and uncommented, and that the cron job runs to completion. The clean step runs at the end of each sync and removes files no longer referenced by any index. If disk pressure is urgent, run apt-mirror manually and watch the clean phase in its output.
Clients report “Release file is not valid yet” or hash mismatches
This almost always means the client’s clock is wrong or the mirror synced mid-update. Check the client’s date with timedatectl, and re-run sudo apt update after the next mirror sync completes. Avoid pointing clients at the mirror while a sync is in progress if you see this repeatedly; schedule syncs outside maintenance windows.
apt update is slow despite the local mirror
Check that clients really use the mirror: run sudo apt update and confirm the host shown is your mirror, not the public archive. Also verify the mirror host’s web server is not throttled and that the client resolves the mirror hostname to the LAN address rather than a public one.
Permission denied on /var/spool/apt-mirror
apt-mirror runs as root, but the web server worker (usually www-data) needs read access to the mirrored tree. The default permissions from apt-mirror are world-readable, so if you tightened them, restore read and execute permissions for others on the mirror directories or adjust the web server user accordingly.
Conclusion
A local apt mirror ubuntu server is one of the highest-value pieces of infrastructure you can add to a multi-server Ubuntu environment. One daily sync replaces dozens of redundant internet downloads, updates complete at LAN speed, and your fleet keeps patching even when the public archive is slow.
Start with the four components for Noble, schedule the nightly sync, serve the tree over HTTP, and migrate clients in batches, verifying apt update on each one. For authoritative details on repository management, see the official Ubuntu documentation on APT. Once the mirror is routine, your update windows will get shorter, quieter, and far more predictable.