Network File System

From Oxxus Wiki

Jump to: navigation, search

This file system management feature, NFS, has the ability to manage file system remotely, over network, as well as via Internet or Intranet. It allows for fast, seamless sharing of files across a network.

You'll find a complete, step-by-step guide below to setting up NFS. Setting up NFS involves configuring the server and then configuring the client.

Contents

Setting up the Configuration Files

Three main configuration files, /etc/exports, /etc/hosts.allow, and /etc/hosts.deny, will need to be configured for NFS server.

Configuration involves editing files, adjusting contents and saving changes. Any editor, like nano can be used.

An entry in /etc/exports will usually look like this:

directory machine1(option11,option12)
machine2(option21,option22)
directory
the directory that you want to share
machine1 and machine2
client machines that will have access to the directory
optionxx
ro - the directory is shared read only,
rw - the client machine will have read and write access to the directory.

Here's a working example below.

A typical setup for /etc/exports might look like this:

/usr/local   192.168.0.1(ro) 192.168.0.2(ro) 
/home        192.168.0.1(rw) 192.168.0.2(rw)

Here we are sharing /usr/local read-only to slave1 with ip 192.168.0.1 and slave2 with ip 192.168.0.2.

/etc/hosts.allow and /etc/hosts.deny

These two files specify which computers on the network can use services on your machine.

The first step in doing this is to add the followng entry to /etc/hosts.deny:

portmap:ALL

Secondly, you need to add an entry to hosts.allow to give any hosts access that you want to have access.

service: host [or network/netmask] , host [or network/netmask]

Host is IP address of a potential client.

Assuming the setup is as above, the only things to do is to allow access to slave1.foo.com and slave2.foo.com. Assumption is made that the IP addresses of these machines are 192.168.0.1 and 192.168.0.2, respectively. A following entry could be added to /etc/hosts.allow:

portmap: 192.168.0.1 , 192.168.0.2

Once configuration is set, NFS services can be started up and remote system's file will be available with permissions set in above configuration files.

NFS depends on the portmapper daemon, either called portmap or rpc.portmap.

It will need to be started first. It should be located in /sbin but is sometimes in /usr/sbin. Most recent Linux distributions start this daemon in the boot scripts, but it is worth checking that it is running before you begin working with NFS (just type ps aux | grep portmap).

For RedHat related distributions use following commands below from account's shell prompt:

/etc/init.d/portmap start
/etc/init.d/nfs start

After executing these commands your system's ready for NFS services.

Verifying that NFS is running

After executing command rpcinfo quota you should get something similar:

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

Making Changes to /etc/exports later on

If you need to change your /etc/exports file, the changes you make may not take effect immediately. You should run the command exportfs -ra to force nfsd to re-read the /etc/exports file. If you can't find the exportfs command, then you can kill nfsd with the -HUP flag.

Contact About Us Support Network Servers Java Hosting Oxxus.net Order Now! Dedicated Servers VPS Hosting Tomcat Hosting Java Hosting Money Back Guarantee Privacy Policy Oxxus.net Terms of 
Service Contact About Us Servers Networks Support Domain Names SSL Certificates Java Wiki Tutorials E-learning 
Platforms