Setting up NFS Linux client for Netgear ReadyNAS Duo
What is NFS?
NFS stands for Network File System and it is used to transfer files from one computer to another. It's very effective in terms of speed and reliability. It differs from other protocols mostly by its representation to the user, shared resources are shown as local folders instead of network shares. For example, you can browse in to a folder /home/user/shared/ and access files as if they were on your local hard drive, instead of clicking on the 'Network' button in the file manager and waiting for the resources to be found. More detailed description at http://en.wikipedia.org/wiki/Network_File_System_(protocol).
Easy, it's roughly twice as fast as CIFS (also known as smb or samba). CIFS pretty much means that it's a Microsoft Windows Network. Twice as fast? It's based on a rough measurement by moving large files in a home network environment, and not on a scientifically measured experiment :) You will probably notice the difference when moving a large movie over the network for example.
Netgear ReadyNAS Duo works with CIFS right out of the box when you set up the shares in the web-based user interface, (i.e. 192.168.?.?/admin) and your Linux distribution will most probably find it right away. But when you already have Linux on your computer, there's no reason really to use the inadequate CIFS file system.
One other reason to use NFS is that the shared resource is mounted on the file system on boot or when connection to the network has been established. There's no need to wait for the file manager to discover the shares, as is the case with CIFS. Waiting for things to happen is for Windows users.
Usage of Apples AFP protocol is not covered in this how to, but if you have a Macintosh (Macbook, iMac... or what ever), it is a good choice.
Configuring the NAS
Open the Netgear web-based user interface with your web browser. The address depends on your configuration (usually something like 192.168.?.?/admin in a regular home network). Check your router settings.
Enable NFS file sharing protocol
Go to Services – Standard File Protocols and enable NFS.
The number of NFS threads is by default 1. If you are expecting that several machines use the shared resources simultaneously, increase the number of threads. 8 simultaneous threads is quite common in many Linux startup scripts. Try and see what works for you. I only have two threads for 6 computers in the household and it works just fine. There's usually only one machine accessing shared content at any given time.
As you can see here, I have also enabled CIFS and AFP protocols. There's a couple of Windows machines and a Mac in my household, which also have access to the NAS (Network Attached Storage). It is possible to use NFS with Macintosh (of course :) and even with Windows (Never tested my self...).
Create a new share in Shares - Add Shares:
I already have few shares configured, but I'll make another one for this example.
I'm am now creating a share called 'test'. The Public Access check box only affects CIFS and AFP protocols. Check or uncheck it, it's up to you. Hit Apply at the bottom of the screen when you're done.
Once finished adding the share test, click back to Share Listing on the left hand side menu bar. NFS is not automatically started. Hit the NFS edit button.
Default access can be set to Read/Write if you are in a home network (Usually trusted clients...) or setup separate read-only, write-enabled or root privilege-enabled hosts. I have used IP numbers of each machine as host identification.
And just like before... remember to hit apply when done. Management by user-basis is not included in this how-to. Every machine in the home network can access this share. We are now done setting up the ReadyNAS NFS host. Next up, the clients...
Setting up NFS clients
This setup works in Ubuntu 11.10 and Linux Mint 12.
Check that you have NFS client installed by typing following in terminal:
|$ sudo apt-get update|
|$ sudo apt-get install nfs-common|
Lets start by creating a folder NAS in the user home directory (write in terminal):
|$ cd $HOME|
|$ mkdir NAS|
Create a sub folder for 'test' share. This way we can have several different shares in NAS folder (one for media or data etc...). You are free to name the folder what-ever you want and put it where ever you feel like putting it, of course :)
|$ cd NAS|
|$ mkdir test|
|$ sudo mount -t nfs -o proto=tcp,port=2049, 192.168.1.22:/test /home/user/NAS/test/|
This needs a little bit of explaining. Sudo gives root privileges to mount a NFS file system. '-o' option defines the protocol to be used(TCP) and port number(2049). This is the standard port-number for NFS. '188.8.131.52' is the IP address of the Netgear NAS, witch is propably different in your configuration. Rest is paths to source and target of the mount respectively.
Now you should be able to copy files to the shared resource 'test' or view the contents using your favorite file manager (the folder is probably empty at this stage.
Making the mount permanent
This configuration will work only until you reboot your machine, therefore we have to make some changes in the /etc/fstab file. It is read by the system upon every boot and file-systems listed in it are mounted automatically.
Let's open this file by writing following line in the terminal:
|$ sudo nano /etc/fstab|
This will open a terminal based text editor. You can also use gedit(GNOME) or kate(KDE) instead of nano if you are using a graphical interface. Nano should be easy enough to use though.
Let's add following line(s) at the end of the file:
|192.168.1.22:/test /home/user/NAS/test nfs _netdev,auto 0 0|
Lines beginning with a '#' are considered comments and omitted by the system. '# NAS' here is just a reminder for what is being mounted. Otherwise the line is quite straight forward in its syntax. 'nfs' of course is our file system. The '_netdev' option makes the system wait with the mount until a network connection has been established. 'auto' tells the system to mount it on startup. Zeros at the end are used by dump and fsck respectively, more importantly they are told not to bother with this mount. Fsck is a utility that is used to check and repair a file system, where as dump is a simple backup utility.
Save fstab and exit. To be sure that the mounted NFS share will work after boot, save your work and reboot by typing:
|$ sudo reboot|
This configuration has been tested on Ubuntu 11.10 (Oneiric Ocelot) and Linux Mint 12 distributions. Should there be problems or inaccuracies with this how-to, please contact me at djwk(at)lnxdev.com