I ran into a problem this week with our RHEL 6 server exporting to RHEL 5.5 clients. I was exporting mounts with a NFS3 syntax, which work until I made one additoinal random export. Then, suddenly, all the clients lost their NFS mounts and I had to quickly figure out NFS4 syntax. Here’s what I learned.
In NFS3, one would edit the /etc/exports file with all the nfs exports and their options. Then you would run an:
exportfs -a #export all
exportfs -rv #delete old exports that are no longer valid, then reexport
exportfs -v #to see the current exports, you would run
NFS4 uses mostly the same commands and syntax as NFS3 with the big difference that the exports can be virtualized, or I like to say realitiveized. The most important part to understand is that a primary export directory will be defined by adding the fsid=0 option in the /etc/exports. this directory can be anywhere on your local filesystem; I’ll use the example of a directory called /exports
This is where NFS3 and NFS4 start to diverge. As mentioned, with NFS3, one would simply export the direct path as a mount. For example, say that the filesystem you want to export is /foo/mydir . Now your NFS3 export may look like:
However with NFS4, you’ll want to make a directory in /exports called mydir (or whatever you want), then bindmount /foo/mydir to /exports/mydir. you can do this in the fstab:
/foo/mydir /exports/mydir none bind
Then, in your exports, you want to export /exports/mydir instead of /foo/mydir:
When you now run ‘exportfs -rv‘ you’ll see /foo/mydir exported still (which is a bit confusing)
To now mount /foo/mydir on a client, you refer to relative path from your /exports directory (denoted with the fsid=0). An fstab entry may look like:
myserver:/mydir /mydir nfs4 rw,auto,hard,intr
trying to mount /exports/mydir will result in a can’t find directory error message.