I already setup a LDAP centralized directory, to manage consistency of the authentication (see LDAP server installation article)
But I would like to find the same files at the same place.
Solution: centralized resources, shared by NFS + automount
First, I will use my Freenas (NAS4Free now) server to share directories via NFS
I created one directory per user.
The disk structure is important on this NAS, because there is a little “trick” there (may be linked to NFS or may be linked to FreeBSD, or just to my technical ignorance of them…):
- I have 2 logical disks, respectively mounted under
- I decided to create a sub-directory
/mnt/Tom/Usersthat will host each and every user directory (
/mnt/Tom/Users/user1as an example)
Once the users directories are created, I need to ensure NFS server is going to share them.
This is quite simple: if not already done, via the FreeNAS web interface, go to the Service “NFS”, and create the share…
… only ONE SHARE, corresponding to your logical disk mount point (
/mnt/Tom in my case), and activate the “Share all sub directories” option to be able to share sub-directories one by one.
Remember to “apply your changes” in the interface, to get NFSd restarted with the new configuration, by pressing the appropriate button !
Note: you may need to increase the number of NFS servers, in the “Settings” tab, also – I put 12:
I strongly advice you to test that you can mount those NFS shares from another machine, by launching some nfs client commands:
sudo mount freenas:/mnt/Tom/Users/user1 /mnt/user1
sudo mount freenas:/mnt/Tom/Users/user2 /mnt/user2
Note: on the FreeNAS server, I activated LDAP authentication, and binded it to my LDAP internal server, in order to ensure consistency of the UID/GID over the network. This is done through menu “Access” then “LDAP”.
Once “simple” NFS mount tested on the client -as explained above- you will need to configure your machine to “automount” required directories from the NAS central repository.
You need to install autofs package:
sudo apt-get install autofs
Then, configuration of the automount tables has to be done, first in
As I’m not going to use NIS/NIS+ tables (I already use LDAP), I will setup those files manually. This is VERY simple in my case !
In order to properly setup autofs configuration files, I need to design how users directories are going to be managed locally and remotely.
- Remotely, they are located under
/mnt/Tom/Users/xxxx, as seen above.
- Locally, I decided not to mount directly under
/homeis already containing local users that would be hidden if I mix local and LDAP users directories). I will mount them under
Doing this is very simple:
- no need to create
/home/Users, the automounter will do it automatically
/etc/auto.master, and just enter the following line:
(no need for anything else in the file !)
This redirects the automounter to an indirect table, when looking for an entry starting with
/etc/auto.home, and type:
Using wildcards is very powerful: no need to maintain users names or whatever! Just rely on the “*” to match any key (in that case the directory name after a reference to /home/Users/), and the “&” to refer to the same key (but in the name of the NFS resource).
Once you have stop/start autofs (
sudo /etc/init.d/autofs stop \; /etc/init.d/autofs start), you can test by a simple
ls -l /home/Users/user1 that should mount your NAS resource automatically (you can check with a simple “mount” command afterwards, to confirm the mounting action).
If it does not, you can troubleshoot the real issue, by:
– stopping autofs (
sudo /etc/init.d/autofs stop)
– starting automounter manually in a specific window:
sudo automount -f -v
=> this should help you debug your issue
Last but not least
As this is combined with LDAP information, you should make sure the LDAP attribute “homeDirectory” is properly set to the expected value that will trigger the automounter.
In my case, all my users should have a “homeDirectory” = /home/Users/user1 (for user = “user1″)
You can modify your LDAP database very easily, whether through the CLI, or using tools, such as phpldapadmin,…