Work in progress

This site is in the process of being reviewed and updated.

Setting Up The Client

With NFSv4, all of the shares are located under one main export. Therefore, the client only needs a single mount point. We now need to create the mount point for our connection. For this Trail, we'll use the name of the NFS server as the mount point name.

[DIRxSRVx10:root@client ~]# mkdir /mnt/nfs1

The client mount configuration is set in the /etc/fstab file. Although all of the exports on the server are located under "/exports", the configuration needs to specify the root connection of "nfs1:/" and not "nfs1:/exports". Using the "/" (root) mount instructs the client to connect to the root share which was earlier configured on the server with the "fsid=0" option. Note that we are using the "sec=krb5p" option, to mount using Kerberos credentials.

[DIRxSRVx10:root@client ~]# vi /etc/fstab

nfs1:/    /mnt/nfs1    nfs4    sec=krb5p,auto,rw,nodev,sync,_netdev,proto=tcp,retry=10,rsize=32768,wsize=32768,hard,intr 0 0

Now that the connection is configured on the client, the mount can be established with the following command.

[DIRxSRVx10:root@client ~]# mount /mnt/nfs1

The share can also be mounted on the command-line. Note that we are providing the "-o sec=krb5p" option, to mount using Kerberos credentials.

[DIRxSRVx10:root@client ~]# mount -t nfs4 nfs1:/ /mnt/nfs1 -o sec=krb5p,async,auto,exec,_netdev,nodev,rw,retry=5,rsize=32768,wsize=32768,proto=tcp,hard,intr

A listing of the mounted share shows whether the connection was successful.

[DIRxSRVx10:root@client ~]# mount -l
nfs1:/ on /mnt/nfs1 type nfs4 (rw,addr=10.0.0.2)

You can now list the subordinate mounts on the remote server.

[DIRxSRVx10:root@client ~]# ls -l /mnt/nfs1
drwxr-xr-x  4 root root 4096 Jan  1 06:07 distros
drwxr-xr-x  4 root root 4096 Jan  1 06:07 sge
drwxr-xr-x  3 root root 4096 Jan  1 06:07 users

Now your test user, such as "hnelson," should be able to read, write, modify, and delete files and directories in the /mnt/nfs1/users directory. When they create files, their ownership will not be squashed to "nobody". For all practical purposes, the NFSv4 filesystem looks like a local filesystem.

Any files the "root" user writes to the NFS filesystem will have their ownership "squashed" to "nobody".

For any of the read/write exported shares, you should be able to read/write files.

[DIRxSRVx10:hnelson@client ~]# cd /mnt/nfs1/users
[DIRxSRVx10:hnelson@client users]# ls
users.tmp
[DIRxSRVx10:hnelson@client users]# touch temp.txt

For the read-only share 'distros', you should be able to view and copy files. But, if you try to write a file to the directory, you will get an error:

[DIRxSRVx10:hnelson@client ~]# cd /mnt/nfs1/distros
[DIRxSRVx10:hnelson@client users]# ls
distros.tmp
[DIRxSRVx10:hnelson@client users]# touch temp.txt
touch: cannot touch `temp.txt': Read-only file system

The client and server are now configured with the NFSv4 protocol.

Wrapping Up
  1. If you are done with this Trail, make sure to unmount:
    [DIRxSRVx10:root@client ~]# umount /mnt/nfs1
    
  2. You should also remove the NFS entry from /etc/fstab if you will not be using the remote share any more.
Notes
  1. You can directly mount directories that are underneath the NFSv4 server's exported root. For example:
    nfs1:/distros
    nfs1:/sge
    nfs1:/users
    
  2. You can use the df and du commands to see how much space is on the remote filesystem:
    [DIRxSRVx10:root@client ~]# df -h /mnt/nfs1
    Filesystem            Size  Used Avail Use% Mounted on
    nfs1:/                80G   594M 79.6G   1% /mnt/nfs1
    [DIRxSRVx10:root@client ~]# du -h /mnt/nfs1
    646K    /mnt/nfs1
    
  3. You may have to add nfs4 to the list of filesystems to exclude from the nightly updatedb run. For example in Fedora you would add "nfs4" to the PRUNEFS list in /etc/updatedb.conf.
  4. Another useful mount option is the "noauto" option. The client machine will not automatically mount the NFS share during system startup. Instead, the share will be mounted only when the 'mount' command is used.
  • No labels