Thursday, October 14

How to create a local YUM repository?

What is YUM?

YUM stands for Yellowdog Updater Modifier. This is a Package Management Tool (PMT) for the RedHat Package manager. YUM has been used for quite a long time. But, now in RHEL 8, we have a modest version of “yum” called “dnf” which stands for Dandified YUM. Although both the commands work fine in RHEL 8 Linux but DNF is much faster, as some of the bugs have been removed.

Why you need a local yum repository?

If you are working on a Linux system which is not having internet connectivity or behind some VPN where you cannot access the internet without using PROXY and you are tired of installing packages using rpm utility, then use YUM. RPM utility cannot install dependency packages. YUM resolves the package dependency automatically. It can automatically perform system updates, including dependency analysis and obsolete processing based on “repository” metadata.

All ISO’s provided by RHEL always have some packages in them. If we talk about numbers then somewhere around 4000 packages.

Step 1: Mount the RHEL ISO

[root@linuxhawks ~]# mkdir local_yum
[root@linuxhawks ~]# mount -o loop /dev/cdrom /media

Step 2: Copy all contents to local_yum directory

[root@linuxhawks ~]# cd /media
[root@linuxhawks media]# cp -r * /root/local_yum

Step 3: Install createrepo package

[root@linuxhawks ~]# cd /root/local_yum/Packages
[root@linuxhawks Packages]# rpm -ivh createrepo*

Step 4: Now make a configuration file for your YUM repo for installing packages from local_yum. Use the below commands. Delete all other repo files under folder /etc/yum.repos.d/

[root@linuxhawks ~]# cd /etc/yum.repos.d
[root@linuxhawks yum.repos.d]# vi local_yum.repo 

Insert below lines in the vi editor:

[local_yum]       #same as file name
name=local repo
gpgcheck=0        #disable check signature of packages

Step 5: Enter below command to check packages in repo

[root@linuxhawks ~]# yum repolist

Step 6: Syntax for yum

yum [options] [command] [package..]

Step 7: Help for yum

[root@linuxhawks ~]# yum -h
Loaded plugins: fastestmirror
Usage: yum [options] COMMAND
List of Commands:
check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.

Step 8: See the yum.conf(5) man page for more information on plugin related configuration options.

[root@linuxhawks ~]# man yum

Step 9: Important yum files and locations


Leave a Reply

Your email address will not be published. Required fields are marked *


Enjoy this blog? Please spread the word :)