Brad Stewart

What is a NSF (Network File System)? -- Part 1

Discussion created by Brad Stewart Employee on Jun 17, 2010

What is a NSF (Network File System)?

 

And how do I set it up?

 

A Network File System is a way that allows a client system (such as an iMX51 running Ubuntu Linux) to access files over a network in a manner similar to how local storage is accessed.  Sounds pretty neat.  This means I can mount files and directories on a host Linux PC and access them on my client just if they were stored locally. 

 

This is quite useful in a number of ways.   I can boot my iMX board from the images (kernel and root file system) that is stored on the host.  This saves time since I don’t have to program these onto memory cards or internal Flash.  Or I can compile code on the PC and run them on the client. Plus, the NFS is used for remote debugging.   And I can run big multimedia files on my iMX51 board that are stored on the PC. 

 

NFS has been around for a long time.  It was originally developed around 1984 for the Unix operating system.  This enabled the concept of “the network is the computer,” first coined by John Gage at Sun Microsystems.

 

My setup is as follows:  I have both a dedicated laptop with Ubuntu 9.10 installed and Windows XP laptop running VMware with Ubuntu 9.10 (so both work).  The laptops are connected to my router.  The client is an i.MX51 EVK (Babbage Board) that runs Ubuntu 9.10.  I recently upgraded to Version 10.04 and it works great. 

 

 

HOST SETUP

 

The host is running Ubuntu.  The host is the NFS server (called "nfs-kernel-server") and is often already installed in Ubuntu.  You can verify installation by typing,

 

$ sudo /etc/init.d/nfs-kernel-server restart

           

If this doesn’t work, then install the NFS server by typing,

 

$ sudo apt-get nfs-kernel-server

 

You may also need to install the next two files

 

$ sudo apt-get nfs-common

$ sudo apt-get portmap

 

NOTE:  For VMware users, you may need to change the settings of the Virtual Machine Network Adapter to “NAT” to enable Internet access.  This could disable the local connection to the Client, so after you download any applications, set the Network adapter back to “Bridged.”  This applies only to a host running VMware.  I haven’t found out a way to fix this, so any suggestions are welcome.   This does not apply if you use a dedicated Linux host.

 

OK.  Now that the server is installed, you need to tell it what directories to allow remote access.  This information is stored in a file called etc/exports.  In my system, I allow the client to access all the files and directories in user-space /home/brad.

 

So type,

 

$ sudo gedit /etc/exports

 

And add the following line (in my case, I want to share /home/brad on the host):

 

            /home/brad *(rw)

 

plus any other directories you want to share.

 

The “*(rw)” grants read-write privileges to all files and subfolders in /home/brad.  More options are available.  Google “ubuntu /etc/exports”.  Another good source are the Ubuntu forums (http://www.ubuntugeek.com/nfs-server-and-client-configuration-in-ubuntu.html). 

 

Save the file and then restart the server by typing

 

$ sudo /etc/init.d/nfs-kernel-server restart

 

Check to make sure the NFS server is working.  You can list the services by typing

 

            $ rpcinfo –p

 

The command rpcinfo makes a RPC (remote PC) call to an RPC server and reports what it finds.  The -p probes the portmapper on host, and prints a list of all registered RPC programs. 

 

You should see something like this:

 

          program vers proto   port

          100000    2   tcp    111  portmapper

          100000    2   udp    111  portmapper

          100011    1   udp    749  rquotad

          100011    2   udp    749  rquotad

          100005    1   udp    759  mountd

          100005    1   tcp    761  mountd

          100005    2   udp    764  mountd

          100005    2   tcp    766  mountd

          100005    3   udp    769  mountd

          100005    3   tcp    771  mountd

          100003    2   udp   2049  nfs

          100003    3   udp   2049  nfs

          300019    1   tcp    830  amd

          300019    1   udp    831  amd

          100024    1   udp    944  status

          100024    1   tcp    946  status

          100021    1   udp   1042  nlockmgr

          100021    3   udp   1042  nlockmgr

          100021    4   udp   1042  nlockmgr

          100021    1   tcp   1629  nlockmgr

          100021    3   tcp   1629  nlockmgr

          100021    4   tcp   1629  nlockmgr

 

This says that we have NFS versions 2 and 3, rpc.statd version 1, network lock manager (the service name for rpc.lockd) versions 1, 3, and 4. There are also different service listings depending on whether NFS is using TCP or UDP.  UDP is usually (but not always) the default unless TCP is explicitly requested.

 

If you do not see at least portmappernfs, and mountd, then you need to restart NFS or recheck /etc/exports to make sure there are no syntax errors.

The last step is to find out what IP address the host has.  This is done by typing ifconfig and noting the value in the printout.  In my case, the router assigned the virtual machine an address of 192.168.69.140

 

End of Part 1.

Outcomes