Thursday, July 12, 2012

Locks in NFS, migrating to NFSv4, nobody:nogroup problem

The file lock handling mechanism is not very well in nfsv3. But for a long time this did not cause much problem in our lab setup, debian squeeze with nfs and nis, mainly because there weren't much students and such programs were not used that use locks. But things changed, and use of openoffice and iceweasel increased. Both the softwares create a lock file in the user's home directory and use exclusive locks on them. This caused frequent problems. When all the people are using any one the two software at the same time for some of them it worked and for others the software would just hang at startup. What actually used to happen is that after allowing a certain number of lock requests nfs would just make other requests wait, thereby hanging the programs.

When googling this site popped up-
http://www.crazysquirrel.com/computing/debian/servers/setting-up-nfs4.jspx
They were also facing the problem with locks and upgrading to NFSv4 solved it. So I decided to give it a try using the tutorial of crazysquirrel and ubuntu community documentation.

The setup of the server went smoothly. But configuring client did not went so smooth.

First of all, all directories and files on the client mounted from server using nfs are owned by uid/gid 4294967294:4294967294. Fixing that was easy because, it's already given there in ubuntu help.

In /etc/default/nfs-common set
NEED_IDMAPD=yes
and restart nfs-common
invoke-rc.d nfs-common restart

That solved uid/gid = 4294967294:4294967294 but now they are being shown as nobody:nogroup. Though this is also mentioned in ubuntu help, but their fix was not working.

Then in syslog(/var/log/syslog) I found idmapd was giving some errors.

rpc.idmapd[xxxx]: nss_getpwnam: name: 'username@domainname' does not map into domain 'localdomain'

So, here idmapd was trying to map the usernames to domain localdomain.
What I found in /etc/idmapd.conf this was written -
[General]
Verbosity = 0
Pipefs-Directory = /var/lib/nfs/rpc_pipefs
Domain = localdomain

[Mapping]
Nobody-User = nobody
Nobody-Group = nogroup

This Domain = localdomain was forcing idmapd to domain name localdomain. So I tried changing Domain to the domain of the lab. That did the trick and nfs was now working perfectly in all the other machines.