My good friend Tony asked for a quick HowTo detailing the steps for setting up YUM to use the RHEL/CentOS/Fedora installation disk as a repository. The OS installation disk contains packages that may not have been installed during initial setup that may be needed at a later time.
- Insert the OS installation disk into the optical drive. If the target system is virtual, make the installation disk image (.iso) available to the virtual machine via the hypervisor.
- OPTIONAL: If the target system is using autofs and autofs is configured to automatically mount optical disks upon insertion we’ll want to unmount the installation disk by running the following from a root prompt:
- # umount /dev/sr0
- OPTIONAL: If the target system is using autofs and autofs is configured to automatically mount optical disks upon insertion we’ll want to unmount the installation disk by running the following from a root prompt:
- Configure the repository. YUM searches repositories listed in /etc/yum.conf and in /etc/yum.repos.d when YUM commands are ran. The most scalable solution is to create a new .repo file in /etc/yum.repos.d for your installation disk. A .repo file requires only 3 things to be valid: A repoid enclosed in square brackets, a friendly name for the repo appearing after the
name=
directive, and a URI giving a location for the repo after thebaseurl=
directive. The following steps will create a .repo file suitable for serving the installation disk from the optical drive:- From a root prompt type:
vi /etc/yum.repos.d/installdisk.repo
- Press i to enter insert mode and paste in the following:
- From a root prompt type:
[installdisk]
name=installdisk
baseurl=file:///installdisk
3. Press <esc> to leave vi’s insert mode and save the file with :wq
- Mount the disk under /installdisk by typing the following at a root prompt (create /installdisk with mkdir if it doesn’t already exist):
# mount /dev/sr0 /installdisk
- Confirm the installdisk repo is visible to yum with the following command:
# yum repolist
- You should see installdisk among the repositories visible to YUM, and if you’re on RHEL/CentOS7 you should see a number indicating the number of packages available in that repository. On the installation disk for CentOS Linux release 7.8.2003 I get 4,021 available packages.
Troubleshooting:
This is a fine ad hoc solution for installing a couple of packages from the installation disk. Notice that for speed we didn’t install the gpg key that comes with the installation disk. For this reason you might receive a failed gpgcheck error when attempting to install packages from this repository. In order to get around this add the gpgcheck=0
directive to /etc/yum.repos.d/installdisk.repo file.