Wednesday, March 21

Solaris 10 NFS version when using the automounter

Classic problem, new stuff is cool and all. But sometimes people (like myself) can't be bothered with configuring everything to the extreme so all new features are working and are compatible. For basic things, the basics is enough.
Take NFSv4, a default Linux box these days do support NFSv4 but I'm usually to lazy to configure it and just slap in an old NFSv3 line in my exports file. Fine with me, fine with most things, except one thing.
The Solaris 10 automounter, it detects the NFSv4 support and automatically tries to mount the NFS share in v4 mode when browsing /net.
Sidenote, if you are not familiar with the /net feature in Linux and Solaris it's pretty neat. See it as a cli version of "My network neighbourhood" in Windows. You can simply cd to /net/<machine name>/<share path> and the automounter will mount that share on that machine. Easy peasy.
Back to my problem, what do I want? I want the default NFS mount level to be vers=3.
Easy change, just uncomment and set NFS_CLIENT_MAXVERS to 3 in /etc/default/nfs.

Here's an example, the machine dolphin is my old trustworthy Linux workstation (yes, I like examples):
[root@marble /]$ cd /net/dolphin/
[root@marble dolphin]$ ls
shared
[root@marble dolphin]$ cd shared
bash: cd: shared: Permission denied
[root@marble dolphin]$ grep NFS_CLIENT_VERSMAX /etc/default/nfs
#NFS_CLIENT_VERSMAX=4
[root@marble dolphin]$ vim /etc/default/nfs
.. edit ...
[root@marble dolphin]$ grep NFS_CLIENT_VERSMAX /etc/default/nfs
NFS_CLIENT_VERSMAX=3
[root@marble dolphin]$ cd shared
[root@marble shared]$ ls -l
total 84
drwxrwxr-x 6 hlinden hlinden 4096 Mar 8 15:29 apps
drwxrwxr-x 6 hlinden hlinden 4096 Sep 7 2006 archive
drwxrwxr-x 11 hlinden hlinden 12288 Mar 21 16:32 download
drwxrwxr-x 15 hlinden hlinden 4096 Mar 1 11:05 tmp
[root@marble shared]$

5 comments:

Anonymous said...

I have similar issues with nfs4. I don't want to bother changing 100's of machines just because a few have issues with NFS 4. How can I tell a AIX 5.3 server to only support NFS 3? Or how can I tell a Solaris client to use NFS 3?

Anonymous said...

I meant to say a Solaris client that isn't running Solaris 10. It's easy to set the NFS versions on Solaris 10, but what about 9, 8, 7 etc?

Anonymous said...

The body of your post has the parameter name wrong:

I'ts NFS_CLIENT_VERSMAX not NFS_CLIENT_MAXVERS.

thanks

SecMF said...

I changed /etc/auto_master to read:

/net -hosts \
-nosuid,nobrowse,vers=3

works under solaris and should work with earlier versions

Preston said...

My problem is that my Linux client has NFSv4 support, but the NIS-provided automounter mapping files didn't specify the nfs version, but the servers didn't support NFSv4.

In /var/log/messages, I would see:
Mar 11 14:32:39 hostname kernel: NFS: bad mount option value specified: vers=4

The solution is to create an executable automapper that grabs the data from NIS on each call, and adds in the nfsvers=3 option. This also has the advantage of not having to restart autofs whenever the mapping files are updated.

For example, in my setting, NIS provides auto.disks which lists the automounts for /disks. In my auto.master file, I have:
/disks auto.disks
Then in the same directory (/etc/autofs), I have a file auto.disks that is executable and contains:
#!/bin/bash
ypmatch $1 $(echo $0 | sed -e 'sX.*/XX') | sed -e 'sX-X-nfsvers=3,X'

Now it works just as if the NIS-provided mapping file specified the version.