Get faster package downloads with dnf
The package manager in Fedora, dnf
, is slow sometimes. But there is a way to make it faster! All we need to do is to set the fastestmirror
option in the configuration file /etc/dnf/dnf.conf
.
With fastestmirror
configured dnf
will try all configured package repositories and select the one that is fastest for us. This depends of our internet connection speed, our location on earth and other factors — but fastestmirror will give us the repository mirror that is the fastest at the moment. This will give us faster downloads of packages and we will save time. Let’s configure!
We open the file /etc/dnf/dnf.conf
with a text editor, I choose vim
, but you can use the editor you like best (nano, emacs or something else):
$ sudo vi /etc/dnf/dnf.conf
In the end of the file we add the following line:
fastestmirror=1
And now the file should like this:
[main]
gpgcheck=True
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
fastestmirror=1
Now we save the file and it’s time to empty the local cache of the package information. This is done with the following command:
$ sudo dnf clean all
Now dnf
will find the fastest mirror and download the packages from that mirror every time we want to upgrade or install packages in our system. Let’s do an upgrade (dnf upgrade
) to see how it works and if it is faster:
$ sudo dnf upgrade
max_parallel_downloads
There is another option we can enable to make downloads faster too. This option is called max_parallel_downloads
and is also configured in the file /etc/dnf/dnf.conf
. As default it is set to 3
, but we can increase the value up to 20
.
Be aware of that multiple downloads will use more bandwidth (internet connection), and if we have a slow internet connection it might take more time to download the packages if we set a higher value for max parallel downloads.
Now we edit the file /etc/dnf/dnf.conf
:
$ sudo vi /etc/dnf/dnf.conf
And in the end of the file we type the following line:
max_parallel_downloads=20
Save the file. The command dnf
will now download up to 20 packages at the same time, which will make installations and upgrades faster.