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.
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.
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.
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 /some/directory/name/userhome1. This can be supported but it will be burden on system resources as each password entry has to be examined from first to last.
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 autohome configuration becomes complicated and it is not recommended.
Next step in setup is to decide where will be virtual base directory and real base directory for home directory creation.
What is virtual base directory and what is real base directory in the context of autohome module?
It all depends on how user accounts are created. If an user account created for user name user1 with home directory /home/user1 then /home will become Virtual Base Directory.
Then what is real base directory? It can be any directory. Only thing that has to be kept in mind is, there should be enough space as all actual files are stored here instead of in virtual base directory.
In most server configurations /home is a separate partition mounted on it. But if /home is made virtual base directory files are not stored in that directory! The solution is, do not mount partition on /home but instead mount it under somewhere else and make it real base directory.
Autodir option -d is used to specify virtual base directory. For example autodir -d /home assuming /home is virtual base directory.
It is little tricky to specify real base directory. real base directory is managed by autohome module so this option must be passed to the module through module suboptions. If the real base directory is /var/autohome then it is specified with option -o as -o realpath=/var/autohome.
Please refer to directory organization under real base directory for detailed explanation of this topic.
autohome does support this kind of organization. The suboption used to specify directory organization desired, is with level suboption. For example, -o level=2.
Suboption skel can be used if skeleton path is not default value /etc/skel like -o skel=/some/other/dir.
Suboption noskel can be used with -o to indicate not to copy skeleton files to home directories when created.
First, import user accounts from centralized database like, for example, ldap.
Next, autofs module must be loaded. This can be done as described in autofs kernel module section.
If /home is to be used for home directories then /home will become virtual directory and specified to autodir with -d /home option.
Assuming autohome module is located at /usr/lib/autodir/autohome.so, this module can be loaded with autodir as -m /usr/lib/autodir/autohome.so. Note that full path for module is given.
Where actually real home directories reside is given with realpath suboption. If it is /autohome, it can be given as realpath=/autohome.
With all these options autodir can be started as,
# autodir -d /home \ -m /usr/lib/autodir/autohome.so \ -o 'realpath=/autohome' \
Once Autodir is started, /home directory will be blank in the beginning. Whether Autodir working properly or not can be tested by changing directory to one of the home directories as root user or as the owner of the home directory.