You can use find-ubuntu-mirrors to find alternative repository mirrors for Ubuntu. It will check mirror lists and test the mirrors to see if they’re working or not.

When it finds mirrors that are compatible with your preferences, it will output the mirrors in Apt’s sources.list format.

The script also allows you to find Ubuntu mirrors for different architectures like:

  • ARM (armhf & aarch64)
  • RISC-V (riscv64)
  • PPC (ppc64el)
  • IBM Z (s390x)

Click here to view the source code for find-mirrors.sh.

Usage

$ export URL="https://raw.githubusercontent.com/alexdelorenzo/find-ubuntu-mirrors/master/find-mirrors.sh"
$ curl -Ls "$URL" | bash

Passing options

The script takes the following positional arguments or environment variables:

Position Variable name Description Default value
1 $ARCH Architecture that the mirrors support amd64
2 $DISTRO Version of Ubuntu the mirrors support focal
3 $REPOSITORY The apt repository main
4 $PROTOCOL The apt repository protocol http
5 $JOBS Number of concurrent network connections 4

Here’s the syntax:

$ curl -Ls "$URL" | bash -s $ARCH $DISTRO $REPOSITORY $PROTOCOL $JOBS

If you want to find alternatives for aarch64 architectures while checking 6 repositories concurrently, you can do this:

$ curl -Ls "$URL" | bash -s aarch64 focal main http 6

You can also use environment variables instead:

$ export ARCH=aarch64 DISTRO=focal JOBS=6
$ curl -Ls "$URL" | bash

Output

The script will output the mirrors it finds in Apt’s sources.list format:

$ curl -Ls "$URL" | bash
deb http://mirror.kumi.systems/ubuntu-ports/ focal main
deb-src http://mirror.kumi.systems/ubuntu-ports/ focal main

deb http://mirrors.portafixe.com/ubuntu/archive/ focal main
deb-src http://mirrors.portafixe.com/ubuntu/archive/ focal main
...

Requirements

Script

You can check out find-ubuntu-mirrors on GitHub here.

Click here to see the source for find-ubuntu-mirrors below