NFS, an acronym for Network File System, facilitates file sharing and access across a network. Here’s a guide for setting up NFS on both the server and client sides:
Server Setup
Install the NFS kernel:
1
sudo apt-get install nfs-kernel-server
- Create the directory
/exported/storage. Edit the
/etc/exportsfile:1
/exported/storage 192.168.1.0/255.255.255.0(rw,no_subtree_check)
Restart the NFS server:
1
sudo systemctl restart nfs-kernel-serverCheck the server status:
1
sudo systemctl status nfs-kernel-server
Client Setup
Verify if the server is operational:
1 2 3 4
showmount --exports <server-ip> # Or showmount -e <server-ip> # It should display a list of mounted directories
Create a directory for mounting:
1
mkdir /mnt/nfsInstall NFS common utilities:
1
sudo apt-get install nfs-common
Mount the server directory:
1
sudo mount <server-ip>:/exported/storage /mnt/nfs/storageFor
autofsusage, installautofs:1
sudo apt-get install autofs
Add the following line to the end of
/etc/auto.master:1
/mnt/nfs /etc/auto.nfs --ghost --timeout=10
Create the
/etc/auto.nfsfile and add the following lines:1
storage -fstype=nfs4,rw <server-ip>:/exported/storage
Restart
autofs:1
sudo systemctl restart autofsCheck the mounted storage:
1
df -h