Edit History Actions

NFSv4 with Ubuntu

deutsche Version

NFSv4 with Ubuntu

Tested with

  • Server:
    • Ubuntu Alternate Intrepid Ibex (8.10)

    • Ubuntu Alternate Jaunty Jackalope (9.04)

  • Client:
    • Kubuntu Jaunty Jackalope (9.04)

    • Kubuntu Karmic Koala (9.10 beta)

I had some trouble with this HowTo: https://help.ubuntu.com/community/NFSv4Howto/ Following this guide, the server enabled the NFSv3 protocol only. I carefully read some man files, changed some settings and ended up with a working NFSv4 protocol. I mainly changed stuff, decreasing performance but increasing reliability and integrity. I do not know what did the job of enabling the v4 protocol, so I will give a summary of no-kerberos part from the HowTo above with my changes already applied.

Installation

System should work as a client:

# apt-get install nfs-common 

System should work as a server:

# apt-get install nfs-kernel-server 

There is also a nfs-user-server package. It gives better debug messages but the performance is not as good as the kernel server.

Configuration without Kerberos

This is a simple configuration of NFS without Kerberos. I have tested it on Ubuntu 8.10 (server) and Kubuntu 9.04 (client). Don't use this in a public accessible net. A private LAN behind a NAT, without W-LAN should be ok.

Configuration of the NFS Server

Note: For some reasons, without completely restarting the server computer, there is only the NFS version 3 protocol available.

You have to create a pseudofilesystem of the directories you want to export (share). This easily done with mounting the directories with the --bind option to an export directory. [More infos here].

Make the pseudofilesystem to export (share) the real user directories in /home:

# mkdir /export
# mkdir /export/users 

For instant use:

# mount --bind /home /export/users 

For use after reboot add this to /etc/fstab:

/home    /export/users   none    bind  0  0

Now one would tell the NFS server about this with the exportfs command, but Ubuntu/Debian has a init script to start the server and set the exports, and you can configure some options used in the script with this configuration files:

  • /etc/default/nfs-kernel-server:

    NEED_SVCGSSD=no 
  • /etc/default/nfs-common:

    NEED_STATD=no
    NEED_IDMAPD=yes
    NEED_GSSD=no 
  • If you want to share the files in the subnet 192.168.1.0/24 add the following to /etc/exports. You can replace 192.168.1.0/24 by a single hostname or * (the whole world, i think):

    /export/users    192.168.1.0/24(rw,sync,fsid=0,insecure,no_subtree_check) 
  • (Re)start the service:
    # /etc/init.d/nfs-kernel-server restart

NFSv4 Client

  • Mount the export instantly (replace <NFS-SERVER> with the hostname of the server):

    # mkdir /nfs-home
    # mount -t nfs4 <NFS-SERVER>:/ /nfs-home
  • To mount this after every reboot, add this line to /etc/fstab:

    <NFS-SERVER>:/   /nfs-home   nfs4    _netdev,auto  0  0

    where the auto option mounts on startup and the _netdev option waits until network devices are loaded.

  • If you have a slow network connection and are not establishing mount at reboot, you can change the line in etc/fstab:

    <NFS-SERVER>:/    /nfs-home   nfs4    noauto  0  0

    and execute this mount after a short pause once all devices are loaded. Add the following lines to /etc/rc.local

    # sleep 5
    # mount /nfs-home

I case of error try this:

  • # /etc/init.d/nfs-common restart


CategoryLinux CategoryUbuntu