A few days ago on WeChat, I discovered that Tongji University actually has its own open source software mirror site. Our lab servers are still using Alibaba Cloud’s CentOS 7 mirror. Wouldn’t it be much faster if we switched to the university’s mirror? So how to change CentOS 7 public repo to Tongji University’s mirror?

Steps:

  1. What is yum
  2. Backup original repo files
  3. Download Tongji University mirror repo config file
  4. Update yum cache

What is yum

Yum (Yellow dog Updater, Modified) is a package manager developed by the Duke University team by modifying the Yellow Dog Linux updater. It is a command-line front-end package manager based on RPM. It can automatically download RPM packages from specified servers and install them, handling dependencies by installing all required packages at once without the hassle of multiple downloads and installs. It is used by Yellow Dog Linux itself, as well as Fedora and Red Hat Enterprise Linux.

Simply put, yum searches for rpm packages (RPM is a very fast software installation format for Red Hat/CentOS Linux systems) on specified servers. If found, it installs them directly to the system, making it convenient and fast. The source of yum packages is the yum Repository, which is the server where yum queries software information.

All CentOS 7 yum repository files are stored in the /etc/yum.repos.d directory, with files ending in .repo containing the yum repository configuration. Here, we replace CentOS-Base.repo with the Tongji University CentOS 7 mirror address. Tongji University’s mirror site will be set as the designated server for CentOS 7.

Backup Original Repo Files

First, backup the original repo files so you can revert if the new repo has issues.

cd /etc/yum.repos.d 
mv CentOS-Base.repo CentOS-Base.repo.back

Download Tongji University Mirror Repo

I didn’t find the config file on the Tongji University Open Source Mirror official site, so here is the repo file I prepared. You can directly use this if you want to use Tongji University’s mirror.

wget -O /etc/yum.repos.d/CentOS-Base.repo https://www.bobobk.com/wp-content/uploads/2019/12/CentOS-Base.repo

Update yum Cache

Update the yum cache:

yum makecache

To summarize the full command sequence for switching CentOS 7 repo to Tongji University mirror:

cd /etc/yum.repos.d 
mv CentOS-Base.repo CentOS-Base.repo.back
wget -O /etc/yum.repos.d/CentOS-Base.repo https://www.bobobk.com/wp-content/uploads/2019/12/CentOS-Base.repo
yum makecache

Then when you install software with yum, you’ll get 100 Mbps intranet speed — super fast!

Summary

This article replaced CentOS 7 software sources with Tongji University’s mirror, greatly improving yum package installation speed. Similarly, for other Linux systems, replace the corresponding repo files in their respective directories.