Linux - Network File System (NFS)
Table of Contents
Network file system (NFS) is a simple approach for share and exchange files in Unix/Linux. This post summarizes its installation and configuration.
Installation
pacman -S nfs-utils
Configuration
Server
Edit /etc/exports
, e.g.
# /etc/exports - exports(5) - directories exported to NFS clients # # Example for NFSv2 and NFSv3: # /srv/home hostname1(rw,sync) hostname2(ro,sync) # Example for NFSv4: # /srv/nfs4 hostname1(rw,sync,fsid=0) # /srv/nfs4/home hostname1(rw,sync,nohide) # Using Kerberos and integrity checking: # /srv/nfs4 *(rw,sync,sec=krb5i,fsid=0) # /srv/nfs4/home *(rw,sync,sec=krb5i,nohide) # # Use `exportfs -arv` to reload. /home 192.168.2.0/24(rw,async,subtree_check,no_root_squash) /opt 192.168.2.0/24(ro,async,subtree_check,no_root_squash)
And then enable and start the service.
systemctl enable nfs-server.service systemctl start nfs-server.service
Client
Add the corresponding entries in /etc/fstab
, e.g.
server:/opt /opt nfs4 ro,_netdev,soft,async 0 0 server:/home /home nfs4 rw,_netdev,soft,async 0 0