If you’re a Fedora user, you may have noticed that the default package repository can sometimes be slow to update or lack the latest software versions. To fix this, you can change the default Yum repository to a faster or more up-to-date one.
Here’s a step-by-step guide on how to do it:
- find the repository you want to use instead of the default one. You can search for it using the yum repolist command. For example, to search for the EPEL (Extra Packages for Enterprise Linux) repository, enter the following command:
yum repolist
explain the some output:
fedora
: the default repository for Fedora systemsfedora-cisco-openh264
: a repository that provides openH264 codecs from Ciscofedora-modular
: a repository that provides modular packages for Fedora systemsrpmfusion-nonfree-nvidia-driver
: a repository that provides non-free NVIDIA driversrpmfusion-nonfree-steam
: a repository that provides non-free Steam packagesupdates
: the repository that provides updates for Fedora systemsupdates-modular
: the repository that provides updates for Fedora modular packages
Each repository has a unique ID and name, and you can choose which ones to use on your system. The default repository fedora
is usually sufficient for most users.
- Now, open the
/etc/yum.repos.d/
directory in your terminal and create a new file with the name fedora.repo. This file will contain the configuration for your new repository.
Tsinghua (Fedora30 or higher version)
$ vim /etc/yum.repos.d/fedora.repo
[fedora]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora/releases/$releasever/Everything/$basearch/os/
metadata_expire=28d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
$ vim /etc/yum.repos.d/fedora-updates.repo
[updates]
name=Fedora $releasever - $basearch - Updates
failovermethod=priority
baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora/updates/$releasever/Everything/$basearch/
enabled=1
gpgcheck=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
$ vim /etc/yum.repos.d/fedora-modular.repo
[fedora-modular]
name=Fedora Modular $releasever - $basearch
failovermethod=priority
baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora/releases/$releasever/Modular/$basearch/os/
enabled=1
metadata_expire=7d
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
vim /etc/yum.repos.d/fedora-updates-modular.repo
[updates-modular]
name=Fedora Modular $releasever - $basearch - Updates
failovermethod=priority
baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora/updates/$releasever/Modular/$basearch/
enabled=1
gpgcheck=1
metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
- Now, run the following command to update the package database::
sudo yum makecache
- Finally, update your package lists again to make sure the new repository is active:
yum update
That’s it! Your Fedora system is now using the new repository. You can check which repository it’s currently using by running the yum repolist command again.
explain the fedora.repo file:
It specifies the name of the repository, the version of Fedora it contains, the type of architecture, the URL of the repository, the expiration time for the metadata, whether to check the GPG signature of the packages, and the location of the GPG key to use for verifying the signature.
Here’s a breakdown of each line:
[fedora]
specifies the name of the repository. In this case, it’s named “Fedora $releasever - $basearch”.failovermethod=priority
specifies the method for handling failures. In this case, if the first repository fails, the second repository will be used instead.baseurl=https://mirrors.tuna.tsinghua.edu.cn/fedora/releases/$releasever/Everything/$basearch/os/
specifies the URL of the repository. The URL contains the release version, the type of architecture, and the location of the OS packages.metadata_expire=28d
specifies the expiration time for the metadata. In this case, the metadata will expire in 28 days.gpgcheck=1
specifies whether to check the GPG signature of the packages. If set to 1, the signature will be checked.gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
specifies the location of the GPG key to use for verifying the signature. The key file is located at/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
.skip_if_unavailable=False
specifies whether to skip the repository if it’s unavailable. If set to False, the repository will not be used if it’s unavailable.