NFS
Networking/Protocols/NFS
NFS on Linux is typically provided by nfs-kernel-server (server) and nfs-common (client utilities).
Install (Server)
$ sudo apt install nfs-kernel-server -y
Server Status
$ systemctl status nfs-kernel-server
Configuration
NFS is configured via /etc/exports, which defines shared directories and access rights.
Common export options:
| Option | Description |
|---|---|
rw |
Read and write access |
ro |
Read-only access |
no_root_squash |
Root on the client keeps root privileges |
root_squash |
Root on the client is mapped to a normal user |
sync |
Write changes to disk before completing requests |
async |
Reply before changes are committed (faster, less safe) |
Create an Export
$ mkdir -p /home/cry0l1t3/nfs_sharing
$ echo '/home/cry0l1t3/nfs_sharing hostname(rw,sync,root_squash)' | sudo tee -a /etc/exports
$ sudo exportfs -ra
$ sudo exportfs -v
Mount an Export (Client)
$ mkdir -p ~/target_nfs
$ sudo mount -t nfs 10.129.12.17:/home/john/dev_scripts ~/target_nfs
$ tree ~/target_nfs