NFS Divertimento

Some weeks ago, I wrote something about iSCSI. This is a way to show a remote disk in another server as if it was a local disk. You need to care in you client about everything: It is basically like another disk for the initiators.

On the other hand, you can choose using NFS which is a different approach: The server exports the Filesystem (directory or whatever) and it is mounted remotely in the clients. So, the “internals” about the filesystem are managed in the server and not in the client. I only mean that the approaches are different, I don’t want to discuss which one is better. Anyway, the question should be something like “which one is better for what?”.

In this example, I’d like to explain how we can install and use NFS both in our client and our Server

NFS Server

The installation is simple:

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

Once we have installed that software, we only need to think what we want to export, and write that in “/etc/exports” file. For example, let’s imagine we create a new folder /exports/nfs and I want to export that, then I should add the following line to /etc/exports file:

/export/nfs               *(rw,no_root_squash)

and reload the nfs-kernel-server:

sudo systemctl reload nfs-kernel-server

That was pretty easy.

NFS Client

The installation of the client side is even easier than the installation in the server:

sudo apt-get install -y nfs-common

And in order to mount the /export/nfs which our NFS server is exporting, we only need to run the following command (my NFS_SERVER_IP is 192.168.192.10):

sudo mount -t nfs ${NFS_SERVER_IP}:/export/nfs /mnt

Of course, we might want to mount that directory at startup. So we must change our /etc/fstab file adding this line (knowing that my NFS_SERVER_IP is 192.168.192.10):

192.168.192.10:/export/nfs   /mnt    nfs     rw,relatime,addr=192.168.192.10     0 0

We can start working with our NFS.

Leave a Reply

Your email address will not be published. Required fields are marked *