Archive

Archive for the ‘Ubuntu’ Category

How to set up NFS on Ubuntu

December 12th, 2011 No comments

from Ubuntu Docs

Installation

The required packages are different depending on if the system is a client or a server. In this Howto, the server is the host that has the files you want to share and the client is the host that will be mounting the NFS share.

  • NFSv4 client
    # apt-get install nfs-common
  • NFSv4 server
    # apt-get install nfs-kernel-server

After you finish installing nfs-kernel-server, you might see failure to start nfs-kernel-server due to missing entries in /etc/exports. Remember to restart the service when you finish configuring.

For the error message:

mount.nfs4: No such device

You will have to load the nfs module with the command

# modprobe nfs

 

NFSv4 without Kerberos

 

NFSv4 Server

NFSv4 exports exist in a single pseudo filesystem, where the real directories are mounted with the --bind option. Here is some additional information regarding this fact.

  • Let’s say we want to export our users’ home directories in /home/users. First we create the export filesystem:
    # mkdir /export
    # mkdir /export/users

    and mount the real users directory with:

    # mount --bind /home/users /export/users

    To save us from retyping this after every reboot we add the followingline to /etc/fstab

    /home/users    /export/users   none    bind  0  0
  • In /etc/default/nfs-kernel-server we set:
    NEED_SVCGSSD=no # no is default

    because we are not activating NFSv4 security this time.

  • In /etc/default/nfs-common we set:
    NEED_IDMAPD=yes
    NEED_GSSD=no # no is default
  • To export our directories to a local network 192.198.1.0/24we add the following two lines to /etc/exports
    /export       192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async)
    /export/users 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,async)
  • Be aware of the following points:
    • Setting the crossmnt option on the main psuedo mountpoint has the same effect as setting nohide on the sub-exports: It allows the client to map the sub-exports within the psuedo filesystem. These two options are mutually exclusive.
    • Note that when locking down which clients can map an export by setting the IP and subnet mask, 255.255.255.0 does not work. Either do not set any subnet or use /24 as shown. Can someone please provide a reason for this behaviour?
  • Restart the service
    # /etc/init.d/nfs-kernel-server restart

    On ubuntu 11.04 or later you may also need to start or restart the idmapd with:

    # start idmapd   # or...
    # service idmapd restart

 

Categories: Ubuntu Tags: