The UHF of the film world.
Latest news

quietearth [General News 09.28.06]



Looking around on google I didn't see a straightforward howto on the first page for setting up an nfs serve, so here's a little writeup. There are 2 different ways we can do this, in kernel or user space. Of course, kernel is faster so we'll use that one. First off let's install the packages:
# apt-get install nfs-kernel-server nfs-common

This will start multiple services, including portmap and mountd, if you run:
# rpcinfo -p
you'll see what's running. If you're open to the outside you're going to need to block these via hosts.allow and hosts.deny in /etc. Check out the man pages on these for further info.


Now we can modify /etc/exports to make our file system available. This is a different format then a normal unix exports file, but no worries. We can also export via subnet, but I just want to make one host available inside my network, and I want to make it read write. The no_root_squash line makes it so root isn't translated to a nobody id which is default nfs behavior.
/filesystem  hostname(rw,no_root_squash)
and then export the filesystem:
# exportfs -a

Now if we run showmount, we'll see the filesystem available:
# showmount -e
Export list for localhost:
/filesystem hostname


On the remote system where we want to mount from, we might need portmap, lockd, and statd running. This shouldn't be necessary, but your system will pause for a couple of minutes on bootup while it tries to mount it if these aren't installed. So if it's ubuntu, just run:
# apt-get install nfs-common
and then we can modify /etc/fstab and add the line in:
REMOTEHOST:/filesystem /filesystem nfs rw 0 0
and run:
# mount -a

and everything should work fine. This filesystem will now be automatically mounted on every boot.

Tested under dapper and edgy.

Pingbacks

Pingback from http://www.odonnellweb.com/?p=3408
on May 18th, 2007 23:20:43 GMT

Pingback from http://blog.mournival.com/index.php/2007/09/24/nfs-setup/
on September 24th, 2007 18:52:45 GMT


You might also like

avatar

Anonymous (10 years ago) Reply

i tried that on my (dapper) cluster; 1 server; 10 clients (not identical hardware). the result is that only 3 of the machines mount /filesystem automatically; the rest does not. typing mount -a afterwards works...

(hack: i wrote a boot up script that is launched late in the boot process. it waits for a few seconds and then mounts /filesystem. this is ugly, but it works)

avatar

quietearth (10 years ago) Reply

This might just be a udp issue (which is by default how nfs works). Try changing "rw" to "rw,proto=tcp". This should also make it run faster.

Another note is that in fstab all fields should be seperated by tabs, not spaces.

Also if you have multiple clients from the server use:
/filesystem hostname1(rw,..) hostname2(rw,..) hostname3(rw,...)

avatar

Anonymous (10 years ago) Reply

worked great

avatar

Chris (9 years ago) Reply

Hi, this is the best article in this area. Very easy to follow. Great job!

avatar

Peter (6 years ago) Reply

Hmm, thanks very much - clear and concise. Well done.


Leave a comment