NFS
NFS (Network File System) allows sharing directories between Linux systems over a network. NFSv4 is the current recommended version and simplifies things by only requiring a single port (2049/tcp).
Server Setup
Install the NFS utilities (package name varies by distro: nfs-utils on Fedora/Arch, nfs-kernel-server on Debian/Ubuntu).
Define exports in /etc/exports:
Common export options:
rw/ro- Read-write or read-only accesssync- Write data to disk before replying (safer, slower)no_subtree_check- Disables subtree checking, improves reliabilityno_root_squash- Allows root on the client to act as root on the server (use cautiously)root_squash- Maps root to nobody (default, more secure)
Apply changes and start the service:
Verify what's being exported:
| |
Client Setup
Install nfs-utils (or nfs-common on Debian/Ubuntu) on the client.
Mount an NFS share:
| |
For persistent mounts, add to /etc/fstab:
| |
The _netdev option tells the system to wait for network availability before attempting to mount.
Firewall
NFSv4 only needs port 2049/tcp. Older versions (v2/v3) require additional ports for rpcbind, mountd, and lockd which makes firewall configuration more complex. Stick with v4 if possible.
Troubleshooting
If the client gets a "wrong fs type" error, make sure nfs-utils is installed on the client side.
Check what a server is exporting from the client:
| |
Debug mount issues with verbose output:
| |