How to Increase DNF Speed on Rocky Linux

DNF is the package manager for Rocky Linux, handling software installation, updates, and dependency resolution. While DNF works reliably out of the box, its default configuration prioritizes compatibility over speed. By adjusting a few settings, you can significantly reduce download times when installing packages or performing system updates.

This guide walks through the key performance settings in /etc/dnf/dnf.conf, including parallel downloads and fastest mirror selection. By the end, you will have an optimized DNF configuration that downloads packages faster without sacrificing reliability, along with verification steps to confirm the changes are active.

The DNF configuration settings covered here work on Rocky Linux 8, 9, and 10 without modification. All versions share the same default values and accept the same performance optimizations.

Understand DNF Default Settings

Before modifying your DNF configuration, it helps to understand what the defaults are and why they matter. Rocky Linux ships with conservative settings that work on any hardware and network connection, but faster systems can benefit from more aggressive values.

SettingDefault ValueOptimized ValueWhat It Does
max_parallel_downloads310Number of packages downloaded simultaneously
fastestmirrorFalseTrueAutomatically selects the lowest-latency mirror
gpgcheck1 (True)1 (True)Verifies package signatures (keep enabled)
installonly_limit33Number of kernel versions to keep installed
clean_requirements_on_removeTrueTrueRemoves orphaned dependencies automatically

The two settings with the biggest impact on download speed are max_parallel_downloads and fastestmirror. Increasing parallel downloads from 3 to 10 allows DNF to fetch multiple packages at once, while fastestmirror ensures those downloads come from the closest available server.

Check Your Current DNF Settings

First, verify your system has the dnf-plugins-core package installed. This package provides the config-manager subcommand used to inspect DNF settings. Desktop installations include it by default, but minimal server images may not:

sudo dnf install dnf-plugins-core -y

Now display your current DNF configuration to see what values are active:

dnf config-manager --dump | grep -E 'max_parallel|fastest|gpgcheck|installonly|best|skip_if|clean_req'

On a fresh Rocky Linux system (any version), you will see output similar to:

best = 1
clean_requirements_on_remove = 1
fastestmirror = 0
gpgcheck = 1
installonly_limit = 3
max_parallel_downloads = 3
skip_if_unavailable = 0

Notice that fastestmirror = 0 (disabled) and max_parallel_downloads = 3. These are the settings you will optimize in the following steps.

Open the DNF Configuration File

All DNF configuration settings are stored in /etc/dnf/dnf.conf. Open this file with a text editor to make changes. This example uses nano, but vim or any other editor works:

sudo nano /etc/dnf/dnf.conf

The sudo command is required because /etc/dnf/dnf.conf is a system configuration file owned by root. You will see a file that starts with [main] followed by several configuration options. All optimizations go under this [main] section.

Configure Parallel Downloads

By default, DNF downloads only 3 packages at a time. Increasing this number allows DNF to fetch multiple packages simultaneously, which significantly speeds up large updates when you have a reasonably fast internet connection. Add the following line to your dnf.conf file:

max_parallel_downloads=10

This setting instructs DNF to download up to 10 packages concurrently. The official DNF documentation notes that the maximum allowed value is 20, but 10 provides a good balance between speed and system resource usage for most connections.

If you have a very fast connection (gigabit or higher), you can experiment with values up to 15 or 20. However, setting this too high on a slower connection can actually decrease performance because the system spends more time managing connections than downloading data. Start with 10 and adjust based on your experience.

Enable Fastest Mirror Selection

The fastestmirror option makes DNF automatically select the mirror with the lowest network latency for each repository. This is particularly useful because Rocky Linux mirrors are distributed across multiple geographic regions, and your default mirror may not be the closest one. Add this line to your configuration:

fastestmirror=True

When enabled, DNF measures TCP socket latency to find the closest available mirror. It then selects randomly from mirrors with less than twice the lowest latency, which provides load balancing while still preferring faster servers. The first dnf update after enabling this option may take slightly longer while DNF tests mirror speeds, but subsequent operations benefit from the optimized mirror selection.

Save and Test Your Configuration

After adding the performance settings, save your changes. In nano, press Ctrl+O to write the file, then Enter to confirm, and Ctrl+X to exit. Your complete dnf.conf file should now look similar to this:

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
max_parallel_downloads=10
fastestmirror=True

Now verify that your changes are active by running the configuration dump command again:

dnf config-manager --dump | grep -E 'max_parallel|fastest'

The output should confirm your new settings:

fastestmirror = 1
max_parallel_downloads = 10

Test your optimized configuration by running an update with the --refresh flag, which forces DNF to fetch fresh metadata from the repositories:

sudo dnf update --refresh

Watch the output during the download phase. With parallel downloads enabled, you should see multiple packages downloading simultaneously rather than one at a time.

Additional DNF Configuration Options

Beyond parallel downloads and mirror selection, several other DNF settings affect package management behavior. The defaults for these options are sensible for most users, but understanding them helps you make informed decisions about your configuration.

Package Signature Verification (gpgcheck)

gpgcheck=1

This option is enabled by default and should remain enabled. It ensures DNF verifies GPG signatures on all packages before installation, protecting your system from tampered or malicious packages. Never disable this unless you have a specific, temporary need and understand the security implications.

Kernel Version Retention (installonly_limit)

installonly_limit=3

This setting controls how many kernel versions DNF keeps installed. The default value of 3 is sensible for most systems: it keeps your current kernel plus two previous versions as fallbacks. This allows you to boot an older kernel from GRUB if an update causes hardware problems, while preventing old kernels from consuming excessive disk space.

Automatic Dependency Cleanup (clean_requirements_on_remove)

clean_requirements_on_remove=True

When enabled, DNF automatically removes packages that were installed as dependencies but are no longer required by any installed package. This keeps your system clean and prevents orphaned packages from accumulating over time. This option is already enabled by default on all Rocky Linux versions.

Handling Unavailable Packages (skip_if_unavailable)

skip_if_unavailable=False

This option controls whether DNF continues with a transaction when some packages cannot be downloaded. The default value of False causes the entire update to fail if any single package is unavailable, which is the safest behavior because it prevents partial updates. Some administrators set this to True on systems where updates must proceed despite temporary mirror issues, but this means you might miss security updates if packages are consistently unavailable.

Version Selection Policy (best)

best=True

When best=True (the default), DNF always attempts to install the latest available version of a package. If dependency conflicts prevent this, the transaction fails with an explanation rather than silently installing an older version. Setting best=False allows DNF to fall back to an older version that can be installed, which may help resolve dependency issues but means you might not get the newest packages. Most users should keep the default.

Complete Optimized Configuration

Here is a complete dnf.conf file with all recommended settings. You can copy this to /etc/dnf/dnf.conf to apply all optimizations at once:

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
max_parallel_downloads=10
fastestmirror=True

After saving the file, run dnf config-manager --dump | grep -E 'max_parallel|fastest' to confirm your changes are active. The values should show max_parallel_downloads = 10 and fastestmirror = 1.

Related Rocky Linux Guides

If you are setting up a new Rocky Linux system, you may also want to enable additional repositories for software not included in the base distribution. The EPEL repository guide covers adding Extra Packages for Enterprise Linux, which provides thousands of additional packages. The RPM Fusion guide explains how to add multimedia codecs and other software with licensing restrictions. Both repositories benefit from the DNF optimizations covered in this guide.

Conclusion

You have configured DNF for faster package downloads on Rocky Linux. The key optimizations are parallel downloads (10 concurrent connections instead of 3) and automatic fastest mirror selection (choosing low-latency servers over the default mirror order). These changes apply to all package operations including updates, installs, and dependency resolution. Run dnf config-manager --dump periodically to verify your settings remain active after system updates.

Leave a Comment

Let us know you are human: