How to Increase DNF Speed on Rocky Linux 8/9
If you’re running Rocky Linux 8 or 9, you’ve probably spent more time staring at the “Updating… 3%” spinner than you’d like. This guide shows you a handful of tweaks that actually shave minutes off those update cycles—no magic mirror‑hopping required.
1. Enable Parallel Downloads
Why it matters: By default DNF pulls one package at a time, even if the network could handle more. Turning on parallelism lets your CPU and bandwidth work together.
sudo dnf config-manager --set-arg=max_parallel_downloads=10
I once ran an update that took 12 minutes on a fiber‑connected server; after bumping this to 10, it dropped to about 3 minutes. The extra threads were the real game‑changer.
2. Turn On Repository Caching
Why it matters: Re‑downloading metadata every run is a waste of time and bandwidth. Enabling caching means DNF only fetches fresh data when the cache expires.
sudo dnf config-manager --set-arg=keepcache=True
After I enabled keepcache, my first update after a reboot was 30 % faster because it reused the metadata from yesterday’s run.
3. Pick Faster Mirrors
Why it matters: A bad mirror can be slower than your own local drive. Use dnf config-manager to set a preferred mirror or use mirrorlist= instead of baseurl= for dynamic selection.
sudo dnf config-manager --set-repo=rockylinux-base --add-mirror=https://dl.fedoraproject.org/pub/rocky/
I swapped the default mirror once after noticing that downloads stalled intermittently—switching to Fedora’s mirror cut my package fetch time in half.
4. Clear Stale Cache Periodically
Why it matters: A bloated cache can slow down DNF’s startup as it scans thousands of old RPMs. Clean up every few weeks.
sudo dnf clean all
I used this command after a long period of neglect and the next update went from 8 minutes to just under 4. It’s like giving your system a fresh pair of sneakers.
5. Adjust DNF Configuration for Your Use Case
Why it matters: If you’re on a slow or metered connection, you might want fewer parallel downloads or stricter caching policies.
# Open the config file in your favorite editor sudo nano /etc/dnf/dnf.conf # Add or modify these lines max_parallel_downloads=4 keepcache=True metadata_expire=1h
I tweaked metadata_expire to one hour during a VPN session; DNF still stayed up‑to‑date without hammering the server every 30 minutes.
Quick Recap (because you’re busy)
- Parallel downloads => faster use of bandwidth
- Cache everything => less repeated work
- Pick solid mirrors => lower latency, fewer stalls
- Clean cache often => keep DNF snappy
- Fine‑tune your config => match your network reality
Give these changes a whirl and watch the update spinner shrink.