Setup NFS Share on Debian Print

  • 0

NFS is a network-based file system that allows computers to access files across a computer network. This guide explains how you can expose folders over NFS from one instance to another. Rcs's private network feature assists you with securing the connections between the instances. Please note that you can also expose folders over NFS through the public internet, however, I highly recommend that you use a private network for security purposes. If you are sharing folders in different locations, an encrypted VPN can replace the private network. This guide assumes that both instances are in the same location.

Requirements

  • Two instances in the same physical location.
  • Debian 7 or newer.
  • Private networking enabled.
  • 10 minutes time.

Private network

Before getting started, ensure that your instances can ping each other and that they both have an unique IP assigned. For example, you can use these commands in order to comply with this article:

Server

ifconfig eth1 up
ip addr add 192.168.0.1/24 dev eth1

Client

ifconfig eth1 up
ip addr add 192.168.0.2/24 dev eth1

Once the servers can ping one another, continue on for configuration changes.

Server configuration

The following commands are run on the server-side on which the folder to be exposed is located. First, we start with installing the NFS server.

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

Now we can create the directory which will be exposed.

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

In order to expose the directory over NFS, open the file /etc/exports and attach the following line at the bottom:

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

Start the NFS Server.

service nfs-kernel-server restart

Client configuration

We can now continue with mounting the folder on the client.

mkdir /mnt/share
mount 192.168.0.1:/opt/share /mnt/share

By running df -h, you can ensure that your operation was successful:

root@client> df -h
192.168.0.1:/opt/share  25.1G  0G  25.1G  0% /mnt/share

Additionally, by creating a file on the client and then checking the server, you will see the file appearing on the server immediately.

Conclusion

NFS is a great way to share files between multiple instances when using a central storage node. Happy hacking!

NFS is a network-based file system that allows computers to access files across a computer network. This guide explains how you can expose folders over NFS from one instance to another. Rcs's private network feature assists you with securing the connections between the instances. Please note that you can also expose folders over NFS through the public internet, however, I highly recommend that you use a private network for security purposes. If you are sharing folders in different locations, an encrypted VPN can replace the private network. This guide assumes that both instances are in the same location. Requirements Two instances in the same physical location. Debian 7 or newer. Private networking enabled. 10 minutes time. Private network Before getting started, ensure that your instances can ping each other and that they both have an unique IP assigned. For example, you can use these commands in order to comply with this article: Server ifconfig eth1 up ip addr add 192.168.0.1/24 dev eth1 Client ifconfig eth1 up ip addr add 192.168.0.2/24 dev eth1 Once the servers can ping one another, continue on for configuration changes. Server configuration The following commands are run on the server-side on which the folder to be exposed is located. First, we start with installing the NFS server. apt-get install nfs-kernel-server nfs-common Now we can create the directory which will be exposed. mkdir /opt/share chown nobody:nogroup /opt/share chmod 755 /opt/share In order to expose the directory over NFS, open the file /etc/exports and attach the following line at the bottom: /opt/share 192.168.0.2(rw,sync,no_subtree_check) Start the NFS Server. service nfs-kernel-server restart Client configuration We can now continue with mounting the folder on the client. mkdir /mnt/share mount 192.168.0.1:/opt/share /mnt/share By running df -h, you can ensure that your operation was successful: root@client> df -h 192.168.0.1:/opt/share 25.1G 0G 25.1G 0% /mnt/share Additionally, by creating a file on the client and then checking the server, you will see the file appearing on the server immediately. Conclusion NFS is a great way to share files between multiple instances when using a central storage node. Happy hacking!

Was this answer helpful?
Back

Powered by WHMCompleteSolution