My linux world » srv-nfs

srv-nfs


Prerequiste

I assume that you have a Centos installation.

Installation

You can copy/paste this script and use it to configure automatically your server.

  1. echo "install nfs tools"
  2. dnf -y install nfs-utils
  3.  
  4. echo "start nfs on startup"
  5. systemctl enable rpcbind.service
  6. systemctl enable nfs.service
  7.  
  8. echo "start service"
  9. systemctl start rpcbind.service
  10. systemctl start nfs.service
  11.  
  12. echo "add right to anonymous user NFS (id 65534)"
  13. mkdir -p /opt/nfs
  14. chown 65534:65534 /opt/nfs
  15. chmod 755 /opt/nfs
  16.  
  17. echo "add rule to enable connection for client 192.168.0.10 (must set ip address)"
  18. cat > /etc/exports << "EOF"
  19. /opt/nfs 192.168.0.10(rw,sync)
  20. EOF
  21.  
  22. echo "enable rules"
  23. exportfs -a
  24.  
  25. echo "add service nfs (ports 111,2049,4045) to firewall"
  26. echo "to find port list : rpcinfo -p"
  27. firewall-cmd --permanent --add-service nfs
  28.  
  29. echo "reload firewall-cmd"
  30. firewall-cmd --reload
  31.  
  32.  

Client side

echo "install nfs tools"
yum -y install nfs-utils nfs-utils-lib
 
echo "start nfs on startup"
chkconfig rpcbind on
chkconfig nfs on
 
echo "start service"
service rpcbind start
service nfs start
 
# Add this line to you /etc/fstab:
# myserver:/opt/nfs  /mnt/nfs   nfs      rw,sync,hard,intr  0     0

That’s all 🙂


Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.