This documentation provides step-by-step instructions for setting up an NFS (Network File System) server and client. NFS allows sharing files between systems on a network, making it a convenient solution for file storage and sharing.
Author: Stanley Chinedu Ogada
- Prerequisites
- Setting Up NFS Server
- Configuring NFS Server
- Setting Up NFS Client
- Mounting NFS Share on Client
- Automounting NFS Share
- Conclusion
Before proceeding, ensure the following:
-
Server and Client Machines:
- You have two machines: one to act as the NFS server and the other as the client.
- Both machines are connected to the same network.
-
User Privileges:
- You have administrative access to both the server and client machines.
-
Install NFS Server:
sudo apt update sudo apt install nfs-kernel-server
-
Create a Directory to Share:
sudo mkdir /shared_directory
-
Set Permissions:
sudo chown nobody:nogroup /shared_directory sudo chmod 777 /shared_directory
-
Edit Exports File:
Open
/etc/exports
using a text editor:sudo nano /etc/exports
Add the following line to allow access to the shared directory:
/shared_directory client_ip(rw,sync,no_subtree_check)
Replace
client_ip
with the IP address of your client machine. -
Restart NFS Server:
sudo systemctl restart nfs-kernel-server
-
Install NFS Client:
sudo apt update sudo apt install nfs-common
-
Create a Local Mount Point:
sudo mkdir /mnt/nfs_share
-
Mount NFS Share:
sudo mount server_ip:/shared_directory /mnt/nfs_share
Replace
server_ip
with the IP address of your NFS server.
-
Install autofs:
sudo apt install autofs
-
Configure Autofs:
Open
/etc/auto.master
:sudo nano /etc/auto.master
Add the following line at the end:
/mnt /etc/auto.nfs_share
Create
/etc/auto.nfs_share
:sudo nano /etc/auto.nfs_share
Add:
nfs_share -fstype=nfs,rw,sync,no_subtree_check server_ip:/shared_directory
Restart autofs:
sudo systemctl restart autofs
You have successfully set up an NFS server and client, allowing seamless file sharing between machines. Adjust configurations based on your specific requirements.
Note: This documentation was authored by Stanley Chinedu Ogada. If you have any questions or encounter issues, feel free to reach out for personalized assistance.