You could earn up to $300 by adding new articles!Get Started Now
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. Vultr'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.
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:
ifconfig eth1 up ip addr add 192.168.0.1/24 dev eth1
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.
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:
Start the NFS Server.
service nfs-kernel-server restart
We can now continue with mounting the folder on the client.
mkdir /mnt/share mount 192.168.0.1:/opt/share /mnt/share
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.
NFS is a great way to share files between multiple instances when using a central storage node. Happy hacking!