Optimizing APT updates with apt-mirror-updater

The story started when I diagnosed my friend's laptop running Ubuntu, and running apt update is getting really slow even with my high-speed internet just getting around 100kbps updating the APT sources.

It turns out the default repository that the laptop uses, is farther than our current location which is in Jakarta.

When using Ubuntu on the desktop, you could always use the built-in Select Best Server option within the Software & Updates settings page.

Select the best download server dialog box.

Choosing that option solves the bandwidth issue, but what about running it on a Terminal?
Maybe you are running a server, IoT devices, or maybe just want to automate the fastest mirror selection task?

One way to solve that is changing the /etc/apt/sources.list manually, but there must be a better solution.

And it seems I found one good choice, using the apt-mirror-updater package provided by Peter Odding.

If you running the latest Ubuntu versions, and pip3 is already installed then skip this part.

sudo apt install python3-pip

Otherwise, you could continue installing apt-mirror-updater by running this command.

sudo pip3 install apt-mirror-updater

Then run the following command to start finding the best mirror server.

sudo apt-mirror-updater --auto-change-mirror

After executing the command above, it will start finding the fastest repository and in my case, it found one at idcloudhost servers.

That's it, and it only takes around 10 minutes to update Ubuntu from a fresh install.

Subscribe to A Gema's Ramble.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.