Revision 2 of 2026-11-25 18:54 UTC by tux, the current one. Current version - History
NFS
5.1
NFS (Network File System) shares directories between Linux and other Unix machines. The server exports a directory, and the clients mount it like a local disk. To share with Windows machines, see Samba instead.
Install
On the server and on each client:
# spk-add nfs-utils
It brings rpcbind and the NFS kernel modules: linux-lts-fs on
x86_64, linux-nfsd on i486.
The server
The directories to share and who may mount them are listed in
/etc/exports, one per line: the directory, then each client with its
options between brackets, without a space before the bracket.
/home/tux/share 192.168.1.0/24(rw,sync,no_subtree_check)
/srv/iso 192.168.1.0/24(ro,no_subtree_check)
Here every machine of the 192.168.1.x network can read and write the first directory, and only read the second. A client can also be a single address or a host name. The exports manual lists all the options.
Start the server, and enable it at boot:
# trame service start nfsd
# trame service enable nfsd
The script /etc/init.d/nfsd loads the nfsd module, starts
rpcbind, exports the directories of /etc/exports, then starts 8
server threads and rpc.mountd. To change the number of threads, set
NFSD_OPTIONS="16" in /etc/daemons.conf.
After a change in /etc/exports, export again and check:
# exportfs -r
# exportfs -v
The client
The client does not need the nfsd service. Ask the server what it
exports, then mount:
# showmount -e 192.168.1.10
# mkdir -p /mnt/share
# mount -t nfs 192.168.1.10:/home/tux/share /mnt/share
Note the form server:/directory. Unmount with umount /mnt/share.
Mount at boot
/etc/fstab is mounted early at boot, before the network is up, so an
NFS line there must have noauto:
192.168.1.10:/home/tux/share /mnt/share nfs noauto 0 0
Then mount it at the end of the boot, from /etc/init.d/local.sh:
mount /mnt/share
On a slow network, Wi-Fi for example, the network may not be ready yet
at that point: mount by hand, or add a sleep 5 before.
Users and rights
NFS knows users by their number, not their name. A file written by uid
1000 on the client belongs to uid 1000 on the server. On SliTaz, the
first user (tux) is 1000: give your users the same numbers on all the
machines. Root on a client becomes nobody on the server, so root
cannot change the files of others through NFS.
Troubleshooting
"access denied by server": the address of the client is not in
/etc/exports, or the directory was not exported again: run
exportfs -r on the server, then exportfs -v.
"Permission denied" when writing: the export is ro, or the uid on
the client has no rights on the directory of the server.
The mount hangs: the server is not reachable, or a firewall blocks
it. NFS uses TCP port 2049, and showmount needs port 111 (rpcbind).
Links
- Handbook: Disks and partitions
- Linux NFS