Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Network Services»NFS»How to Configure NFS Share on Ubuntu 18.04 & 16.04

    How to Configure NFS Share on Ubuntu 18.04 & 16.04

    By RahulNovember 22, 20183 Mins Read

    Network File System (NFS) is a distributed file system protocol. which allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.

    Advertisement

    This article will help you to install and configure NFS on Ubuntu systems and export a directory and mount it on the client system.

    Network Details:

    We have running two Ubuntu 16.04 LTS Systems in same network 192.168.1.0/24, Below given IPs are configured on server and client, which we will use in this tutorial.

    Server: 192.168.1.100
    Client: 192.168.1.110
    

    Step 1 – Install NFS Server on Ubuntu

    In this step, we will describe you to what packages you need to install and how to install them. Also describes who to export and directory using NFS server.

    Use the following command to install the required packages to configure the NFS server.

    sudo apt-get install nfs-kernel-server portmap
    

    Step 2 – Export Shares over NFS

    Now you need to configure NFS to export directory. For this tutorial we are creating a new directory, you may use any existing directory also.

    I need to export /home directory and a new /opt/share directory on my NFS server. /home already exists on my system. Now create a new directory using below command.

    sudo mkdir /opt/share
    sudo chown nobody:nogroup /opt/share
    

    Now edit the nfs server exports configuration file in a text editor as following:

    sudo vim /etc/exports
    

    Add following settings:

    /etc/exports
    /home          192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)
    /opt/share     192.168.1.110(rw,sync,no_subtree_check)
    

    Here /home can be mounted from the system with any IP of 192.168.1.0/24 LAN network. But /opt/share can only be accessed from IP 192.168.1.110.

    Then apply the new settings by running the following command. This will export all directories listed in /etc/exports file.

    sudo exportfs -a
    

    To confirm and view exported directory use following command and you will get output like below

    sudo exportfs -v
    
    [Samput Output]
    /home           192.168.1.0/24(rw,wdelay,no_root_squash,no_subtree_check)
    /opt/share  192.168.1.110(rw,wdelay,no_root_squash,no_subtree_check)
    

    Step 3 – Mount Share on Client Machine

    After completing set up on the server side, login to clients system where we need to configure NFS client and mount exported directory by NFS server.

    Install following packages on NFS client system, which is required to mount the remote directory using NFS protocol.

    sudo apt-get install nfs-common portmap
    

    Now we need to create mount points for mounting remote nfs exported directories.

    sudo mkdir /mnt/share
    sudo mkdir /mnt/home
    

    After creating mount point, mount remote NFS exported directory using following command.

    sudo mount 192.168.1.100:/opt/share /mnt/share
    sudo mount 192.168.1.100:/home /mnt/home
    

    Check mounted file system using below commands. As per below output both NFS mounted directories are listed at end of the result.

    sudo df -h
    
    [Sample Output]
    Filesystem                    Size  Used Avail Use% Mounted on
    /dev/sda1                      20G  2.8G   16G  16% /
    udev                          371M  4.0K  371M   1% /dev
    tmpfs                         152M  812K  151M   1% /run
    none                          5.0M     0  5.0M   0% /run/lock
    none                          378M  8.0K  378M   1% /run/shm
    /dev/sr0                       32M   32M     0 100% /media/CDROM
    /dev/sr1                      702M  702M     0 100% /media/Ubuntu 12.04 LTS i386
    192.168.1.100:/opt/share       20G  2.8G   16G  16% /mnt/share
    192.168.1.100:/home            20G  2.8G   16G  16% /mnt/home
    

    Step 4 – Setup Auto Mount

    Append the following entries to /etc/fstab file to mount NFS directories automatically after system reboot. This will mount directories on startup.

    /etc/fstab
    ...
    192.168.1.100:/home       /mnt/home  nfs  auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0
    192.168.1.100:/opt/share  /mnt/share nfs  auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0
    

    Step 5 – Unmount NFS Share

    If you want to remove the mounted file system, You can simply unmount it using umount command. Also, you need to remove entries from /etc/fstab (if added)

    sudo umount /mnt/share
    sudo umount /mnt/home
    

    NFS NFS Mount NFS Server
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Set Up an NFS Share on Debian

    View 2 Comments

    2 Comments

    1. DMJ on July 27, 2019 10:18 pm

      And what do we do if the NFS share requires a password?

      Reply
    2. Bob on June 5, 2018 11:53 pm

      nice and clear

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting Up Angular on Ubuntu: Step-by-Step Guide
    • Converting UTC Date and Time to Local Time in Linux
    • Git Restore: Functionality and Practical Examples
    • Git Switch: Functionality and Practical Examples
    • Git Switch vs. Checkout: A Detailed Comparison with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.