NFS Server on Ubuntu18.04

This post shares how to implement NFS(Network File System) on Ubuntu18.04.

Machine spec is following.

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Network topology

Setup nfs server.

Install nfs library

$ sudo apt install -y nfs-kernel-server

/share is the directory to share with clients.
Make directory and configure permission on the server.

$ sudo mkdir /share
$ sudo chmod 777 /share
$ sudo chown -R nobody:nogroup /share

Edit /etc/exports to share with clients.
Options are following.
rw : Read and Write.
sync : Synchronize a data immediately.
no_subtree_check : Does not check if a file is in a public directory.

$ cat /etc/exports
/share 192.168.10.0/24(rw,sync,no_subtree_check)

Mount the nfs directory, /share, to /mnt/share on a client. 192.168.11.10 is the IP address of the nfs server.
On a client

$ sudo apt install -y nfs-common
$ sudo mkdir /mnt/share
$ sudo mount -t nfs 192.168.11.10:/share /mnt/share

To persistent mount the directory, edit /etc/fstab .

$ cat /etc/fstab
192.168.10.10:/share /mnt/share nfs defaults 0 0

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store