Friday 24 June 2011

HOWTO: Setup an NFS server and client for LDAP

In this example I am going to setup a shared home directory to hold user homes. You would typically use this if you are using a centralised LDAP server to authenticate users.

Pre-requisites:
A standard Ubuntu server with working network and pingable by name.

You have relocated your local "sudo" user out of the default /home directory.


Configure the Server.

Note:
We are going to use an NFS server to centrally locate our users home directories. Build or select one of your existing Ubuntu servers to act as the host.

My server is called nfs.tuxnetworks.com and I have made sure that it can be pinged by name by my LAN clients.


Login to your NFS server as root;

Install the server software;

~# apt-get install nfs-kernel-server

Create a folder for the user home directories;

~# mkdir -p /store/ldaphomes

To export the directory edit your exports file;

~# vi /etc/exports/

Add this line;
/store/ldaphomes          *(rw,sync,no_subtree_check,no_root_squash)


Restart the NFS server;

~# service nfs-kernel-server restart

Configure the Client.

Install the NFS client;

~# apt-get install nfs-common

We are going to mount our NFS share on /home;

Note:
If you have any home directories in /home, these will become hidden under the mounted directory. Ideally there will be no existing users in /home because you will have shifted your local admin user somewhere else.


Edit your fstab file;

~$ sudo vi /etc/fstab

Add a line like this;
nfs.tuxnetworks.com:/store/ldaphomes      /home  nfs defaults 0 0


Note:
If your /home directory was already being mounted to a block device then you should comment this entry out in your fstab file.

Mount the directory;

~$ sudo mount /home

You can check that it has worked using the df command

nfs:/exports/ldaphomes
                     961432576 153165824 759428608  17% /home


And thats it!

2 comments:

Daniel said...

First thanks a lot for this guide. I'm new to ubuntu and even I still have a problem it's the best one i found.

So far I followed your instuctions step by step on a new ubuntu 11.10 installation.

I get to the point when i should mount the /home directory. Always get the error "mount.nfs: access denied by sever while mounting"

Looked for a solution for days now, but couldn't find one.
Do you have any idea what i did wrong? Or is it possible that it's just not working with 11.10?

Anonymous said...

Нοwdy! Somеοne in my Myspace group shaгed this ѕite with us ѕo І cаmе to look
it ovеr. I'm definitely enjoying the information. I'm book-marking anԁ will
be tweeting this to my followers! Wondeгful blog and bгilliаnt design and style.
my page: the news