Network File System (NFS)
- is an application layer distributed file system protocol originally developed by Sun Microsystems (Sun) in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed (i.e. Network Attached Storage (NAS))
- related: Common Internet File System (CIFS)
NFS - Server
| |
|
Create root NFS directory
sudo mkdir /home/marcuschiu/directory-to-be-shared
Set permissions
sudo chown nobody:nogroup /home/marcuschiu/directory-to-be-shared #no-one is owner
sudo chmod 777 /home/marcuschiu/directory-to-be-shared #everyone can modify files
Define access for NFS clients in /etc/exports file. Example file:
|
To enable access to a single client |
|
|
To enable access to several clients |
|
|
To enable access to an entire subnet |
|
Example file /etc/exports:
/home/marcuschiu/directory-to-be-shared 192.168.111.38/255.255.255.0(rw,sync,no_subtree_check)
Set changes and restart NFS server
sudo exportfs -a #making the file share available
sudo systemctl restart nfs-kernel-server #restarting the NFS kernel
NFS - Client
| |
|
Mount the NFS directory temporarily
sudo mount -t nfs {IP of NFS server}:{folder path on server} /home/client
sudo mount -t nfs 192.168.111.10:/home/marcuschiu/directory-to-be-shared /home/client
Mount the NFS directory PERMANENTLY
In /etc/fstab file add the following line:
{IP of NFS server}:{folder path on server} /var/locally-mounted nfs defaults 0 0
# e.g.
192.168.111.10:/home/marcuschiu/directory-to-be-shared /home/client nfs defaults 0 0