Good day my dear Linux Yogi’s,
this is part two of the NFS Server/Client set up. In part one you and I set up a NFS Server with one share and in this part you are going to set up a client machine to access this share.
I will show you how you can set it up in a way so it will be mounted automatically during boot time so you don’t have to worry about it to manually mount it each time you need it. Let’s get started.
As usual you should make sure that your system is up to date. Run the following commands to ensure it is:
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade sudo apt-get autoremove
In the next step you are going to install the necessary packages for the NFS Client.
sudo apt-get install nfs-common
Next you need to create a folder where you will mount the nfs share from the server. I suggest you follow along and create one in your home folder like that:
!!! Replace itmgr with your login name !!!
In the next step we are going test if the mount will work before we permanently add it to the /etc/fstab file. Run the following command:
sudo mount 192.168.0.104:/srv/nfs /home/itmgr/nfs-share
in order to confirm that indeed the nfs share is mounted run the following command:
and it should return something similar to that:
Filesystem Size Used Avail Use% Mounted on udev 351M 0 351M 0% /dev tmpfs 75M 2.6M 72M 4% /run /dev/sda1 7.1G 1.5G 7.1G 22% / tmpfs 371M 0 371M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 371M 0 371M 0% /sys/fs/cgroup tmpfs 75M 0 75M 0% /run/user/1000 192.168.0.104:/srv/nfs 7.1G 2.3G 4.5G 34% /home/itmgr/nfs-share
Great, now that you know it is working lets un-mount it and adjust the /etc/fstab so that this share will be mounted next time you boot the machine.
Use your favorite editor and edit the file /etc/fstab and add at the bottom of the file the following line:
192.168.0.104:/srv/nfs /home/itmgr/nfs-share nfs rw,sync,hard 0 0
Here is the explanation for it:
- 192.168.0.104:/srv/nfs: This is the source location and path.
- /home/itmgr/nfs-share: This is the destination path.
- nfs: This is the protocol used.
- rw: This enables you to be able to read and write to it.
- sync: This ensures that NFS is following convention to finish request first before it replies.
- hard: This determines the recovery behavior if a request times out and hard means that it will retried immediately.
- 0: This means no dump will be generated
- 0: This means no filesystem check will be scheduled
and this concludes this howto. Next time your system boots up the nfs share, if available, will be mounted automatically.
I hope you liked this article. Please consider to subscribe to this blog and register to the forum to discuss problems and issues you encounter.
Thank you for reading, until next time, Namaste my friends 😉