CentOS 8 ships with 2 repositories: BaseOS and AppStream (Application Stream) – So what’s the difference between the two repositories?
The BaseOS repository consists of the requisite packages required for the existence of a minimal operating system. On the other hand, AppStream comprises the remaining software packages, dependencies, and databases.
Related Read: How to Create Local HTTP Yum/DNF Repository on RHEL 8
Now let’s roll up our sleeves and set up a local YUM/DNF repository in CentOS 8.
Step 1: Mount CentOS 8 DVD Installation ISO File
Begin by mounting the ISO file to a directory of your choice. Here, we have mounted in on
# mount CentOS-8-x86_64-1905-dvd1.iso /opt # cd /opt # ls
Step 2: Create a CentOS 8 Local Yum Repository
In the mounted directory where your ISO is mounted, copy the
media.repo file to the /etc/yum.repos.d/ directory as shown.
# cp -v /opt/media.repo /etc/yum.repos.d/centos8.repo
Next, assign file permissions as shown to prevent modification or alteration by other users.
# chmod 644 /etc/yum.repos.d/centos8.repo # ls -l /etc/yum.repos.d/centos8.repo
We need to configure the default repository file residing on the system. To check the configurations, use the cat command as shown.
# cat etc/yum.repos.d/centos8.repo
We need to modify the configuration lines using a text editor of your choice.
# vim etc/yum.repos.d/centos8.repo
Delete all the configuration, and copy & paste the configuration below.
[InstallMedia-BaseOS] name=CentOS Linux 8 - BaseOS metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/BaseOS/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [InstallMedia-AppStream] name=CentOS Linux 8 - AppStream metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/AppStream/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
Save the repo file and exit the editor.
After modifying the repository file with new entries, proceed and clear the DNF / YUM cache as shown.
# dnf clean all OR # yum clean all
To confirm that the system will get packages from the locally defined repositories, run the command:
# dnf repolist OR # yum repolist
‘enabled’ parameter from
0 in CentOS-AppStream.repo and CentOS-Base.repo files.
Step 3: Install Packages Using Local DNF or Yum Repository
Now, let’s give it a try and install any package. In this example, we are going to install NodeJS on the system.
# dnf install nodejs OR # yum install nodejs
And this is a clear indicator that we have successfully set up a local DNF/YUM repository on CentOS 8.