mkdir /etc/yum.repos.d/bak mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak mount -t iso9660 /dev/cdrom /mnt
cat >/etc/yum.repos.d/media.repo <<EOF [InstallMedia] name=Red Hat Enterprise Linux Server release 7 baseurl=file:///mnt gpgcheck=0 enabled=1 [InstallMedia_HighAvailability] name=Red Hat Enterprise Linux Server release 7 HighAvailability Add-On baseurl=file:///mnt/addons/HighAvailability gpgcheck=0 enabled=1 EOF
# not include dependencies sudo dnf download --destdir ~/soft/ <package-name>
# include dependencies sudo dnf install --downloadonly --destdir ~/soft/ <package-name>
# clean /var/cache/dnf/ or /var/cache/yum/ sudo dnf clean packages
Creating a Yum Repository
To set up a yum repository:
Install the createrepo package:
yum install createrepo
Copy all packages for your new repository into one directory, such as /tmp/local_repo/:
cp /your/packages/*.rpm /tmp/local_repo/
To create the repository run:
createrepo /tmp/local_repo/
This creates the necessary metadata for the yum repository and places metadata in a newly created subdirectory repodata.
The repository is now ready to be consumed by yum. This repository can be shared over the HTTP or FTP protocol, or refered directly from the local machine.
NOTE: When constructing the URL for a repository, refer to the /mnt/local_repo not to /mnt/local_repo/repodata, as this directory contains only metadata. Actual yum packages are in /mnt/local_repo.