How to share a local repository using NFS ?

Solution Verified - Updated

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 reposync for RHEL 7 and RHEL 8 and 9 respectively.

  • Make sure that nfs-utils package is installed.

    # yum install nfs-utils
    
  • Start and enable nfs-server service

    # 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

    1. Add the entry in /etc/fstab file
        # vi /etc/fstab
        <IP of repo server>:/<some>  <mount point> nfs defaults 0 0 
        :wq!
    
        # mount <mount point>
    
    1. 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-release
    

    NOTE:

    • 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.
SBR
Components
Category
Tags

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.