Exercises with NFSv4

  • NFSv4 exports exist in a single pseudo filesystem, where the real directories are mounted with the --bind option.



    Create the export filesytem on the NFS server (the node machine):
    mkdir /export
    mkdir /export/users
    

    Create and mount the real user home directory onto /export/users with --bind option:
    mkdir /home/NFSv4
    mount --bind /home/NFSv4 /export/users
    
    To survive a reboot, the mount can be added into /etc/fstab
    /home/NFSv4    /export/users   none    bind  0  0
    

    In /etc/default/nfs-kernel-server on the NFS server, we set:
    NEED_SVCGSSD=no
    

    In /etc/default/nfs-common on both the NFS server and the client
    NEED_IDMAPD=yes
    NEED_GSSD=no 
    

    Stop statd on both the NFS server and the client:
    service statd stop 
    

    Export the directories from the NFS server to the client by placing the following content in /etc/exports on the NFS server:
    /export desktop01(rw,fsid=0,insecure,no_subtree_check,async)
    /export/users desktop01(rw,nohide,insecure,no_subtree_check,async)
    
    Note, you can keep the old NFSv3 related entries in /home/exports on the server, such as "/home/exports desktop01(rw)"

    Restart the NFS on the server:
    service nfs-kernel-server restart
    


    On the client, create a mounting point and mount the directory from the NFSv4 server:
    mkdir /home/NFSv4
    mount -t nfs4  node01:/ /home/NFSv4
    
    See the mounted directories
    df -h
    

    Check the mounted file system types
    mount
    

    On the NFS server (node), add two directories, /usr/share/doc and /var/log, to the shared file system name space:
    mkdir /export/DOC
    mount --bind /usr/share/doc /export/DOC
    mkdir /export/LOG
    mount --bind /var/log /export/LOG
    
    Modify /etc/exports by adding the export entries for these directories on the NFS server:
    /export/DOC desktop01(ro,nohide,insecure,no_subtree_check,async)
    /export/LOG desktop01(ro,nohide,insecure,no_subtree_check,async)
    
    Re-export the filesystems by running command exportfs on the NFS server as follows:
    exportfs -ra
    

    On the client (desktop), re-mount the NFS file system:
    mount  -o remount  /home/NFSv4 
    
    See the content of /home/NFSv4
    ls /home/NFSv4
    ls /home/NFSv4/LOG
    ls /home/NFSv4/DOC
    

    References:
    NFSv4Howto on Ubuntu
    Configuring a NFSv4 Server and Client on SUSE Linux Enterprise Server 10