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 users directory with /export/users :
    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 we set:
    NEED_SVCGSSD=no
    

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

    Restart /etc/init.d/nfs-common on both the server and the client:
    /etc/init.d/nfs-common restart
    

    Export the directories on the server: in /etc/exports, put
    /export desktop01(rw,fsid=0,insecure,no_subtree_check,async)
    /export/users desktop01(rw,nohide,insecure,no_subtree_check,async)
    
    You can keep /home/exports desktop01(rw) for NFSv3 in /etc/exports.
    /etc/init.d/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 mounted directories
    df -h
    

    Check the file system types
    mount
    

    On the 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:
    /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 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