Posts Setup Network File System (NFS) on ubuntu linux
Post
Cancel

Setup Network File System (NFS) on ubuntu linux

NFS, an acronym for Network File System, facilitates file sharing and access across a network. Here’s a guide for setting up NFS on both the server and client sides:

Server Setup

  1. Install the NFS kernel:

    1
    
     sudo apt-get install nfs-kernel-server
    
  2. Create the directory /exported/storage.
  3. Edit the /etc/exports file:

    1
    
     /exported/storage 192.168.1.0/255.255.255.0(rw,no_subtree_check)
    
  4. Restart the NFS server:

    1
    
     sudo systemctl restart nfs-kernel-server
    
  5. Check the server status:

    1
    
     sudo systemctl status nfs-kernel-server
    

Client Setup

  1. Verify if the server is operational:

    1
    2
    3
    4
    
     showmount --exports <server-ip>
     # Or
     showmount -e <server-ip>
     # It should display a list of mounted directories
    
  2. Create a directory for mounting:

    1
    
     mkdir /mnt/nfs
    
  3. Install NFS common utilities:

    1
    
     sudo apt-get install nfs-common
    
  4. Mount the server directory:

    1
    
     sudo mount <server-ip>:/exported/storage /mnt/nfs/storage
    
  5. For autofs usage, install autofs:

    1
    
     sudo apt-get install autofs
    
  6. Add the following line to the end of /etc/auto.master:

    1
    
     /mnt/nfs /etc/auto.nfs --ghost --timeout=10
    
  7. Create the /etc/auto.nfs file and add the following lines:

    1
    
     storage -fstype=nfs4,rw <server-ip>:/exported/storage
    
  8. Restart autofs:

    1
    
     sudo systemctl restart autofs
    
  9. Check the mounted storage:

    1
    
     df -h