Autodir HOWTO

2004-09-23

Revision History
Revision 1.12006-03-30VRE
Updated according to the new features added to Autodir.
Revision 1.022004-12-25VRE
Minor updates
Revision 1.002004-09-23VRE
Initial release, reviewed by Rahul Sundaram at TLDP
Revision 0.322004-09-13VRE
New sections like requirements and others.
Revision 0.102004-06-24VRE
second draft
Revision 0.92004-06-11VRE
first draft

Abstract

This HOWTO is about Autodir installation, configuration and other issues related to Autodir.


Autodir offers a simple and effective means to create directories like home directories in a transparent manner. It relies on the autofs protocol for its operation.

This document explains how to create directories on demand using Autodir in a transparent way to the applications. This document also explains using transparent backup feature that is possible with Autodir without bringing system down for backup purpose for all directories managed by Autodir.

This is purely technical and unless you also happened to be well-versed with autofs and automount, I request to skip this section.

Autodir uses modules to get specific functionality. The core Autodir implements generic functionality on which modules can exploit and add specific functionality of their own.

At any moment only one module can be added to Autodir. If there are two modules, for example autohome, autogroup, two processes of Autodir should be created so that each process will have required modules attached to it.

For further explanation I chose the autohome module which handles transparent home directory creation.

[Note]Note
  • autohome module creates user home directories on demand if these does not exist already.

  • It is assumed user accounts exists but not their home directories. Either because these accounts were created with the -M option with useradd or these accounts were imported from ldap, NIS or some other external database for which home directories are yet to be created.

  • It also assumed for this explanation only that all user home directories are expected to be in the /home directory.

[Note]Note

Some fine details are intentionally kept aside to make explanation easy to understand.

First autofs file system is mounted on /home directory by Autodir. And this is informed to the Linux kernel that /home is managed by user space application Autodir from now on.

[Note]Note
Do not bother too much about autofs file system if you do not understand about it. Just think some special kind of file system something in similarity with memory based file system but with some additional special properties.

                                +----------------+
                                |  Linux Kernel  |
                                +----------------+
                                  /        \
                                 /          \
                                /            \
                               /              \
   +-------------+       +--------+       +------------+        +-----------------+
   | Application |------>| /home  |<----->|  Autodir   |<------>| autohome module |
   +-------------+       +--------+       +------------+        +-----------------+
                              \                                          /
                               \  +----------------+                    /
                                +-|   /autohome    |<------------------+
                                  +----------------+

Whenever an application or daemon needs access to user's home directory, for example /home/userhome1, they directly enter into /home/userhome1 to access it. Kernel which notice this, informs to Autodir if userhome1 directory does not exist already in /home.

Autodir, in turn, passes this request to autohome module. autohome module does not touch /home directory. Instead it manages real home directories some where else, for example in /autohome as shown in the above figure.

autohome module creates real home directory if it does not exist already in /autohome directory. After it is successfully created or failed to create, whatever the outcome, it is reported back to Autodir along with the path to real home directory -- if successful.

If autohome module reports success, Autodir creates userhome1 directory under /home and mounts real home directory from /autohome on it. At the end Autodir informs this to the kernel whether this whole operation successful or failure. Accordingly kernel allows application to enter the directory or reports that no such directory exists, in case of failure, back to the application.

Before going further it is better to understand the following terms to simplify explanation.

Each virtual directory is mapped to real directory. Which means whatever written or modified to virtual directory is actually sent to real directory.

On reboot of the system real directories and their content remain intact. But virtual directories are again created on demand as exactly as they were before.

Virtual directories are removed if these are not used for a specified time period and created again if necessary. When Virtual directory is removed backup program is started on corresponding real directory if backup is configured.

[Important]Important

Applications should access only virtual directories. Real directories are hidden from applications except for root. But there is one exception. Backup programs always access only real directories.

If source is downloaded from http://www.intraperson.com/autodir/, follow these simple steps to install it.

  • Unpack the source.

    $ tar zxvf <tar file name>

  • Move to the expanded directory and execute the following.

    $ ./configure

    $ make

    # make install

[Note]Note
configure script check for required libraries. If these are not present, it will stop from proceeding.

This section will explain how to configure Autodir so that user home directories are created on demand. For this purpose autohome module is used which deals with specifics of home directory creation.

To load autohome module with Autodir, use option -m. For example, -m /usr/lib/autodir/autohome.so.

[Note]Note

When an application tries to access home directory, that home directory is used to check if there is any user with user name same as the directory being accessed. If user name exist with this criteria then home directory is created. Otherwise no such file or directory is reported back to application.

[Note]Note

autohome does not deal with creating user accounts on local systems or in ldap or in any other database. It only deals with creating home directories once these accounts exist and imported to local system from databases like ldap, NIS.

[Important]Important

It is worth mentioning one limitation with autohome module. It expects that user name and home directory are related to each other. For example, for user user1 the home directory should be /home/user1 or /some/directory/name/user1 but not /home/userhome1 for user user1. This can be supported but it will be burden on system resources as each password entry has to be examined from first to last.

[Note]Note

If the existing user password database is such that user home directories are distributed under different base directories, for example /home/class1/user1, /home/class2/user2332, then more than one Autodirinstance need to be started with module autohome for each class directory.

These options are passed to Autodir to request backup support.

-N

Do not kill backup program. Directory contents accessed at the same time by backup process and by others processes. Useful for maildir type mail storage.

-n

Do not kill backup program but process which try to access the given directory is blocked until backup does not terminate.