โก 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
orapt-fast
(Debian/Ubuntu) to pick fasterapt
mirrors. - Use
dnf config-manager
orfastestmirror=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 newsources.list
.
๐น Step 2: Run It for Your Distribution
sudo netselect-apt stable
Replacestable
withbookworm
,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
usesaria2
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 mirrorsmax_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