Last year i bought myself a nice little Seagate BlackArmor 220 NAS (Network Attached Storage). I’ve set it up at my home and all is fine, the device is running properly for more then a year. At home I’m accessing it via Samba share on the local network, when travelling I was accessing it via FTP (supported by the device). This was all great but unfortunately in this mode I couldn’t directly edit files on the NAS. So i looked for solutions for doing so. One thing i discovered early is that the device supports NFS. I didn’t know much about NFS back then.
The last few days when my itch got really painful to edit files directly on my NAS I started poking around on how to set up a share via NFS which can be accessed and edited from any place where a decent internet connection is available. And after a little bit of research i managed to do that. I will tell you how to do it if you ever need to do so.
Setting up the NAS
Well, first thing your NAS must support NFS. Mine does and in the admin interface of the NAS i can enable and disable NFS. I enabled it and whitelisted the IP addresses from which i’m going to access the NAS. There is no authentication necessary. It works based on IP addresses. So if you whitelist an IP address anyone from that IP can access your NFS share if he knows your NAS’s IP address or hostname (be careful!). That’s all on the NAS side. Of course you can set up NFS not only on a NAS but with your own computer as a server. In this case you need to research the solution because i didn’t try/needed that solution.
Accessing the NFS share from Ubuntu
First of all you will need the nfs-common package. Be sure to get it:
$ sudo apt-get update $ sudo apt-get install nfs-common
Then let’s see what are you sharing via NFS
$ showmount -e server-IP-or-host-name
Ok. Now let’s create a directory on your client machine (in directory /media/username) that will be used to access the share and mount a directory from your NAS to this. For the purpose of this demo let’s assume that your NAS has the hostname imaginarynas.dyndns.org (using dyndns to map a dynamic IP to hostname)
$ cd /media/username $ sudo mkdir myNFS $ sudo mount -o soft,intr,rsize=8192,wsize=8192 imaginarynas.dyndns.org/publicShare /myNFS
Great, now you have in the myNFS directory the contents of the publicShare directory from your NAS
How to permanently mount it
First edit /etc/fstab and add the following to it
imaginarynas.dyndns.org:/publicShare /media/username/myNFS nfs soft,intr,rsize=8192,wsize=8192
And pretty much that’s all. Now i can access my NAS from pretty much everywhere where’s a decent internet connection.