How to share a local repository using NFS ?
Environment
- Red Hat Enterprise Linux (RHEL 9/8/7)
- NFS
- Local RPM repository
Issue
- How to share a local repository using NFS ?
Resolution
On yum repository server
-
NOTE : Make sure repositories or packages are downloaded using DVD or
reposyncfor RHEL 7 and RHEL 8 and 9 respectively. -
Make sure that
nfs-utilspackage is installed.# yum install nfs-utils -
Start and enable
nfs-serverservice# systemctl enable nfs-server # systemctl start nfs-server -
Export the
directory to the required clients :- # vi /etc/exports /<some> <IP range>/<netmask>(permissions) *Example* # vi /etc/exports /data 172.25.0.0/16(ro)
On the client systems
- Create a mount point to mount the shared directory.
-
Temporary usage
Mount the shared directory
# mount -t nfs <IP of repo server>:/<some> <mount point>NOTE: Once the system reboots,
<mount point>will be unmounted automatically. -
Permanent usage
- Add the entry in
/etc/fstabfile
# vi /etc/fstab <IP of repo server>:/<some> <mount point> nfs defaults 0 0 :wq! # mount <mount point>- Create a repository file under
/etc/yum.repos.d/pointing to the shared directory
# cat /etc/yum.repos.d/shared.repo [RHEL-NFS] name=Red Hat Enterprise Linux $releasever - $basearch baseurl=file:///<mount point>/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-releaseNOTE:
- Replace ip_address to NFS server's IP address.
- For RHEL 8 and later, BaseOS and AppStream repositories should be created separately with respective baseurls of each repo directory on NFS Server.
- Add the entry in
SBR
Product(s)
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.