Problem
The default Ubuntu package configuration points to the global archive repository. To improve performance, you can choose from a list of regional mirrors to download from.
Solution
In order to improve the distribution of load across different regions, it is recommended to utilize a local or community-based mirror. Beyond setting up mirrors, systems may attempt to download certain packages from the -security pocket rather than -updates due to package pinning priorities. Large packages, such as linux-firmware, which can often exceed 1GB in size, are sometimes available in both -security and -updates.
To help reduce the load on the security infrastructure and ensure the package is sourced from the correct mirror, you can configure your system to explicitly pull such packages from the -updates pocket.
The following steps will guide you to set up your system to do this.
Modify your apt sources lists to point to a local, regional mirror
The following steps are using Noble as an example of the Ubuntu release being used. Please adjust to the release running in your system (Focal, Jammy, Noble, Resolute, etc)
Back up your current apt sources files
sudo cp /etc/apt/sources.list.d/ubuntu.sources \
/etc/apt/sources.list.d/ubuntu.sources.$$
sudo cp /etc/apt/sources.list /etc/apt/sources.list.$$
This will copy your current sources to numbered backup, so you can revert or restore later as needed.
Use the following list to choose a mirror that is regionally close to you:
https://launchpad.net/ubuntu/+archivemirrors
Click on the mirror you would like to use, and it will provide you with the URL that can be used to configure your apt sources. Note that it will need to take into account the Ubuntu release you are using, as well as the protocol offered by the mirror, which can be http, https, ftp or rsync. Note the URL as that will be needed in the next step.
Replace your default sources with the following by specifying the mirror you would like to use:
For sources.list
deb <protocol>://<url>/ubuntu noble main restricted universe multiverse
As an example, it could be:
deb http://es.archive.ubuntu.com/ubuntu noble main restricted universe multiverse
For sources.list.d/ubuntu.sources (deb822 format)
Types: deb
URIs: <protocol>://<mirror_url>/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: <protocol>://<mirror_url>/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
As an example, it could be:
Types: deb
URIs: http://es.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Types: deb
URIs: http://es.archive.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Update apt package metadata:
sudo apt update
Related documents
Documentation: