Created
November 16, 2020 10:37
-
-
Save imneonizer/20aa7e32646b75437d56f5fb05bed7a5 to your computer and use it in GitHub Desktop.
script for installing nfs server and client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://vitux.com/install-nfs-server-and-client-on-ubuntu/ | |
#Step 1: Install NFS Common | |
sudo apt-get update -y | |
sudo apt-get install nfs-common -y | |
#Step 2: Create a mount point for the NFS host’s shared folder | |
#Your client’s system needs a directory where all the content shared by the host server in the export folder can be accessed. | |
#You can create this folder anywhere on your system. We are creating a mount folder in the mnt directory of our client’s machine. | |
CLIENT_NFS_DIR="/media/NFS" | |
sudo mkdir -p $CLIENT_NFS_DIR | |
#Step 3: Mount the shared directory on the client | |
SERVER_IP="192.168.0.175" | |
SERVER_NFS_DIR="/media/NFS" | |
sudo mount $SERVER_IP:/$SERVER_NFS_DIR $CLIENT_NFS_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://vitux.com/install-nfs-server-and-client-on-ubuntu/ | |
# Step 1: Install NFS Kernel Server | |
sudo apt-get update -y | |
sudo apt install nfs-kernel-server -y | |
#Step 2: Create the Export Directory | |
SERVER_NFS_DIR="/media/NFS" | |
sudo mkdir -p $SERVER_NFS_DIR | |
sudo chown nobody:nogroup $SERVER_NFS_DIR | |
sudo chmod 777 $SERVER_NFS_DIR | |
#Step 3: Assign server access to client(s) through NFS export file | |
# rw: read and write operations | |
# sync: write any change to the disc before applying it | |
# no_subtree_check: prevent subtree checking | |
SUBNET_IP="192.168.0.1" | |
sudo bash -c "echo '$SERVER_NFS_DIR $SUBNET_IP/24(rw,sync,no_subtree_check)' >> /etc/exports" | |
#Step 4: Export the shared directory | |
sudo exportfs -a | |
sudo systemctl restart nfs-kernel-server | |
#Step 5: Open firewall for the client (s) | |
sudo ufw enable | |
sudo ufw allow from $SUBNET_IP/24 to any port nfs | |
sudo ufw status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment