h1

Quick NFS-setup

July 2, 2006


1. NFS-server

Making a NFS-server is done in two steps. Setting up the server and then starting it.


1.1 Configurating the server

The files to edit is placed in the /etc folder.
We are going to edit the exports-, hosts.deny- and the hosts.allow-file.

/etc/exports
The /etc/exports contains information on what dirrectories you share and what permitions the clients have. Use an editor to edit the file and add a line with the following format:

directory mashine1(option11, option12) machine2(option21, option22)...

The options should be “ro”(read only) or “rw”(read/write). Also add a option called “no_root_squash”.
A line could look like this:

/home 192.168.0.(ro,no_root_squash) 192.168.0.1(rw,no_root_squash)

Instead of the 192.168.0. which is a wildcard you can write: 192.168.0.0/255.255.255.0.

/etc/hosts.deny
The /etc/hosts.deny contain information on which deamons the clients are denied to access. Insert a line which sais

ALL:ALL

This makes ALL the protocols unavailable for ALL the users.

/etc/hosts.accept
The /etc/hosts.accept contain information on which deamons the clients are allowed to access. Insert the following lines:

portmap: [client-ip or name]
lockd:   [client-ip or name]
rquotad: [client-ip or name]
mountd:  [client-ip or name]
statd:   [client-ip or name]

And that should complete the server setup.


1.2 Starting the server

Newer releases should start the NFS at startup. Check if it’s already running by running “# rpcinfo -p”. This should show 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

If not, simply run the following commands in the following order: “rpc.portmap”, “rpc.mountd”, “rpc.nfsd”, “rpc.statd”, “rpc.lockd”, “rpc.rquotad”.
Add the commands to /etc/rc.local to make them permanent.
This should start the correct deamons. Now run the “# rpcinfo -p” again and check the table.

Now export your filesystem by typing: “# exportfs -ra”, check it by runnning “# showmount -e [ip-adresse]”.




2. NFS-client

Simlply add the following line in /etc/fstab:

# device	     mountpoint	      fs-type 	  options	dump	fsckorder
[hostip]:[folder]	[folder]	nfs	rw,hard,intr	0	0
linux.uib.no:/home/	/home/linux/	nfs	rw,hard,intr	0	0

The upper line is just a desctiption and does not need to be added, though it’s smart to add it to the top of the table.
Write “# mount -a” to remount all the lines in fstab. Now see if you can access the mount point. You should be able to access it at this point. For permanent mounting… Edit the /etc/rc.local. Add the following line:

mount -a

This run the commando mount -a at the end of your boot sequence.

Now your nfs should work!
For troubleshooting, FAQs and more detailed descripitons read the NFS-HOWTO here.
And remember to check your firewall!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: