โšก Speed Up apt and dnf by Auto-Selecting the Fastest Mirrors

Package updates dragging? On Linux, your mirror source makes all the difference in update/download speeds. Here's how to automatically select the fastest mirrors for apt (Debian/Ubuntu) and dnf (Fedora/RHEL/CentOS) โ€” no manual guessing.


๐Ÿง  TL;DR

  • Use netselect or apt-fast (Debian/Ubuntu) to pick faster apt mirrors.
  • Use dnf config-manager or fastestmirror=true (Fedora/RHEL) to enable faster mirrors.
  • Significant speed boosts for downloads and updates.
  • Commands included for real-time mirror tests.

๐Ÿงช For Debian/Ubuntu Systems (apt)

๐Ÿ”น Step 1: Install netselect-apt (or apt-fast for advanced users)

sudo apt update
sudo apt install netselect-apt -y
netselect-apt benchmarks mirrors for your release and generates a new sources.list.

๐Ÿ”น Step 2: Run It for Your Distribution

sudo netselect-apt stable
Replace stable with bookworm, bullseye, buster, etc., as appropriate.

It creates a new /etc/apt/sources.list. Back yours up and use the new one:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp sources.list /etc/apt/sources.list

โœ… Optional: Use apt-fast for Parallel Downloads

sudo add-apt-repository ppa:apt-fast/stable -y
sudo apt update
sudo apt install apt-fast -y
apt-fast uses aria2 to download packages in parallel = huge speed gains!

๐Ÿ”ง For Fedora, RHEL, or CentOS Systems (dnf)

๐Ÿ”น Step 1: Enable Fastest Mirror Plugin

Edit the DNF config using vim:

sudo vim /etc/dnf/dnf.conf

Add or update these lines:

fastestmirror=True
max_parallel_downloads=5
fastestmirror=True: Automatically ranks fastest mirrors
max_parallel_downloads: Boosts simultaneous downloads (set to 10 if on good bandwidth)

๐Ÿ”น Step 2: Clean Cache and Test

sudo dnf clean all
sudo dnf makecache

Try a package install and see the difference:

sudo dnf install htop

๐Ÿง  Why This Matters

Default mirror selection is rarely optimized for speed. By benchmarking and enabling these tweaks:

  • You reduce wait time for updates/upgrades
  • Install packages faster (especially big ones like Chromium or kernel headers)
  • Improve automation speed for scripts and CI/CD tasks

๐Ÿงผ Restore Defaults (if needed)

If something breaks or feels off, just restore your original backup:

sudo mv /etc/apt/sources.list.bak /etc/apt/sources.list

Or turn off fastest mirror in DNF:

sudo vim /etc/dnf/dnf.conf
# Set fastestmirror=False

โœ… Summary

Distro Method
Debian/Ubuntu netselect-apt or apt-fast
Fedora/RHEL fastestmirror=True in DNF

This quick tweak = faster updates + a smoother Linux experience.


๐Ÿงต Filed under: #linux #apt #dnf #performance #mirror-speed