install nfs | zuhdi.org

Install NFS

Environment

  • Debian 9.7 x64
  • NFS Server 1.3.4-2.1
  • NFS Client 1.3.4-2.1

Log 2019 / 06

1. Install & Configure NFS Server

root@athos:~# apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade

root@athos:~# apt-get -y --no-install-recommends install nfs-kernel-server

root@athos:~# dpkg -l | grep nfs-kernel-server
ii  nfs-kernel-server     1:1.3.4-2.1     amd64     support for NFS kernel server

root@athos:~# systemctl enable --now nfs-server.service

root@athos:~# nfsstat -s
Server rpc stats:
calls      badcalls   badfmt     badauth    badclnt
75         0          0          0          0

Server nfs v4:
null             compound
2         2%     73       97%
(truncated)

root@athos:~# mkdir -p /public/nfs/

root@athos:~# chown root:root /public/nfs/

root@athos:~# chmod 755 /public/nfs/

root@athos:~# echo "/public/nfs/ *(rw,sync,no_root_squash)" >> /etc/exports

root@athos:~# systemctl restart nfs-server.service

2. Install & Configure NFS Client

root@chimera:~# apt-get update && apt-get -y upgrade && apt-get -y dist-upgrade

root@chimera:~# apt-get -y --no-install-recommends install nfs-common

root@chimera:~# dpkg -l | grep nfs-common
ii  nfs-common   1:1.3.4-2.1   amd64   NFS support files common to client and server

root@chimera:~# nfsstat -c
Client rpc stats:
calls      retrans    authrefrsh
47         0          47

Client nfs v4:
(truncated)

root@chimera:~# showmount -e athos.host
Export list for athos.host:
/public/nfs *

root@chimera:~# mount athos.host:/public/nfs /mnt

root@chimera:~# mount | grep athos.host
athos.host:/public/nfs on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=131072,
  wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,
  clientaddr=165.22.255.11,local_lock=none,addr=206.189.81.181)

root@chimera:~# vi /etc/fstab
# /etc/fstab: static file system information.
UUID=8add0c4f-baf9-4734-846d-cb9bd4761926  /     ext4  errors=remount-ro  0 1
athos.host:/public/nfs                     /mnt  nfs   _netdev            0 0

root@chimera:~# mount -a

root@chimera:~# mount | grep athos.host
athos.host:/public/nfs on /mnt type nfs4 (rw,relatime,vers=4.2,rsize=131072,
  wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,
  clientaddr=165.22.255.11,local_lock=none,addr=206.189.81.181,_netdev)

3. exports Manual

root@athos:~# apt-get -y --no-install-recommends install man-db

root@athos:~# man 5 exports

4. exports Cheatsheet

rw read/write filesystem.

ro read-only filesystem.

no_root_squash root account on the client machine will have the same privilege level as the root on the server machine.

root_squash root account on the client to have the same access type as nobody on the server.

no_subtree_check disable file location checks on partial volume exports (this option will speed up transfers on full volume exports).

sync force all transfers to operate in synchronous mode, so all clients will wait until their operations are really done (this can avoid data corruption in the event of a server crash).

Hugo. Malte Kiefer & Zuhdi Najib.