Skip to content

Instantly share code, notes, and snippets.

@souhaiebtar
Last active March 1, 2023 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souhaiebtar/6c09b75c405614adf80c662cbbea1a9c to your computer and use it in GitHub Desktop.
Save souhaiebtar/6c09b75c405614adf80c662cbbea1a9c to your computer and use it in GitHub Desktop.
[share folder using nfs] share folder using nfs on linux #nfs #linux #share

In the server side ( the machine that contain the folder you want to share)

sudo dnf install nfs-utils
sudo systemctl enable rpcbind
sudo systemctl enable nfs-server
sudo service rpcbind start
sudo service nfs-server start

edit /etc/exports and add

/media/nfs/ 192.168.1.2(rw,sync,no_subtree_check)

than run sudo exportfs -avrf

N.B: replace /media/nfs by the folder you want to share and 192.168.1.2 by the ip address of the machine that want to access to folder ( you can put * instead of ip address if you want the folder to be shared with every one

client side (machines that want to read and write into the shared folder)

in the client machine install nfs component using sudo apt install nfs-common portmap -y

than run sudo mkdir -p /mnt/nfs_client to create the folder in which we gonna mount the shared folder (remote folder) and run

sudo mount -o rw,hard,intr -t nfs4 192.168.1.10:/media/nfs /mnt/nfs_client

N.B: the address 192.168.1.10 is the ip address of the machine sharing the folder

thanks goes to https://www.linuxquestions.org/questions/linux-networking-3/system-hangs-when-nfs-connection-is-lost-814578/ and https://kb.netapp.com/Advice_and_Troubleshooting/Data_Storage_Software/ONTAP_OS/What_are_the_differences_between_hard_mount_and_soft_mount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment