Next Previous Contents

10. NFS under Linux 2.2

As I write this Linux 2.2.12 is the current kernel version and to use NFS under it can be a bit of a chore. Or not.

What the status of NFS in Linux 2.4 will be i unknown.

The new big thing in Linux 2.2 is support for a in-kernel nfs server demon, called knfsd in 2.2. This way of implementing nfsd has some advantages, the main one is speed. A Linux 2.2 machine with knfsd is a respectable nfs server. You can still use the old nfsd with Linux 2.2 though, and there are some advantages to using this, mainly simplicity.

If you use a kernel source or binary package made by someone like RedHat (6.0 and later), SuSE (6.1 or later, I belive) or some other professional system integrator they have likely integrated full "knfsd" functionality in their kernel and you need not worry, it will work. Mostly. Until you want to compile a kernel yourself. If you use a stock Linux 2.2 kernel (up to 2.2.12 at least) knfsd will break.

To get this on the air yourself you need to get H.J. Lus knfsd package. This is a collection of patches, and the needed utilities for 2.2 that Lu is maintaining in his spare time. You can get it from your local kernel mirror, the master site is ftp.kernel.org:/pub/linux/devel/gcc/. This is not meant for general consumption. If you find this package confusing please don't try to do this yourself. Wait until a kernel package from your favourite system integrator (e.g., Red Hat, SuSE or ...) appears.

Also, please don't send me questions about this, I can't help you. I do not have any knfsd based servers running. If you find errors or omissions in this documentation, please write to me and I'll revise this HOWTO and release it again.

Still reading? Ok. H.J.Lu posts about new versions of this package on the linux-kernel mailing list. Other issues pertaining to NFS in 2.2 is also posted about there. Read it.

There is one interesting thing to note about the knfsd package. It announces that it supports NFS version 3. However it does not support it. There is an option you can give to stop it from announcing NFS3, or on the clients you can specify "vers=2" in the mount option list.

10.1 The client

The client is almost simple. To get propper locking you need to get statd (from the knfsd package) compiled, installed and started from your boot-scripts. Do that. Statd needs a directory called /var/lib/nfs to function otherwise it will just abort with no error message, so that directory needs to be created before it will run.

Once statd is running you can use the testlk program (in tools/locktest to test if locking of a file on a NFS mounted filesystem works. It should. If it prints No locks available statd is not working.

Actually, you can also avoid locking entierly (not that I recomend this), by giving "nolock" in the mount option list.

As far as I know this is all that's needed to get the client working.

Oh, if you have a Sparc or Alpha NFS server you will find that the nfs client in Linux 2.2 absolutely sucks. The transfer rates to and from the server is so bad that ... you can't imagine. It's far worse than under Linux 2.0. Far. But there is a fix for this of course. The Alan Cox series of 2.2 kernels (which are a bit more experimental than the normal 2.2 kernels from Linus) include a patch to make Linux 2.2 perform when used with Alpha and Sparc servers. If you want to use the Alan Cox 2.2 kernels you should be reading the linux-kernel mailing list and if you do you know where the patch can be found. There home site of this patch is http://www.uio.no/~trondmy/src/, in case you want to try to apply it to a stock 2.2 kernel. This patch will probably not be in Linux 2.4 either, because it requires too many changes in the kernel to be accepted in the current development cycle. Wait for Linux 2.5.

trondmy also has patches to make Linux use NFS version 3, this will also enable you to use tcp as transport mechanism instead of UDP. NFSv3 is is very good for long-haul networks and other networks where the packet loss is non-zero or the latencies are high.

The reason you should read the linux-kernel mailing list to use these patches is that sometimes there are bad bugs discovered in them. Bugs that eat your files. So please beware.

10.2 The server

The nfs server demon under Linux 2.2 and later is called "knfsd". It is tricky to set it up. You have to figure this out all by yourself, or stick to what SuSE, Red Hat and others are releasing in the way of 2.2 kernel packages. Sorry. You can still use the old nfsd under Linux 2.2 though. It's slow but easy to set up.


Next Previous Contents