How to setup NFS Share on Debian

 

 

 

The Network File System, also known as NFS, was created by Sun Microsystems in the early 1980s. As if the remote computer were a local machine, users can access, store, update, and share files on it. NFS offers the convenience of centralized management, which reduces the need for additional software and disk space for individual users. In a similar way to how users access local files, NFS allows access to files on remote hosts.

 

 

Requirements,

 

 

  • You need Debian 7 or later.
  • Two machines in the same location.
  • Private networking enabled.

 

 

 

 

In this article, we’ll demonstrate how to set up a NFS share on Debian. Assign both instances unique IP addresses before starting to ensure that they can ping each other.

 

 

 

 

Let’s begin,

 

 

 

 

 

On Main server

 

ifconfig eth1 up
ip addr add 192.168.1.2/24 dev eth1

 

 

On client server

 

ifconfig eth1 up
ip addr add 192.168.1.3/24 dev eth1

 

 

 

 

 

We now need to configure the main server,

 

 

 

You must execute the following commands on the Main server computer where the folder is located. Let’s first install the NFS server.

 

 

apt-get install nfs-kernel-server nfs-common

 

 

 

We can now create the directory,

 

 

mkdir /opt/share
chown nobody:nogroup /opt/share
chmod 755 /opt/share

 

 

 

If you want to expose the directory via NFS, navigate to /etc/exports then add the following line.

 

 

/opt/share           192.168.1.3(rw,sync,no_subtree_check)

 

 

 

 

Launch the NFS server.

 

 

service nfs-kernel-server restart

 

 

That’s it!

 

 

 

 

 

 

Let’s configure the Client server,

 

 

 

 

 

The folder needs to be mounted on the client now.

 

mkdir /mnt/share
mount 192.168.1.2:/opt/share /mnt/share




Use the df -h command to make sure your operation was successful.

 

 

 

 

Furthermore, if you create a file on the client and then check the server, it appears immediately on the main server.





 

That’s it!

 

 

 

 

 

VPSie is looking forward to embarking on a new journey with you!.

 

 

 

 

 

Get the most out of learning with VPSie.com