18. Managing home directories

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

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

User/home matching

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

User accounts

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

Limitations

It is worth mentioning one limitation of the 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 a burden on system resources as each password entry has to be examined from first to last.

Knowing when not to use autohome

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 is not recommended.

18.1. Base directories for autohome

The next step in the setup procedure is to decide where the virtual base directory and real base directory for home directory creation will be located.

What are the virtual base directory and the real base directory in the context of the autohome module?

This all depends on how user accounts are created. If a user account created for user name user1 with home directory /home/user1 then /home will become the virtual base directory.

Then what is the real base directory? This can be any directory. The only thing that you need to keep in mind is that there should be enough space, as all actual files are stored here instead of in the virtual base directory.

In most server configurations /home is a separate partition. But if /home is the virtual base directory, then files are not stored in that directory! The solution is not to mount a partition on /home but instead mount it somewhere else and make it the real base directory.

The Autodir option -d is used to specify the virtual base directory. For example: autodir -d /home assumes that /home is the virtual base directory.

It is somewhat tricky to specify the real base directory. The real base directory is managed by the 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 the option -o as -o realpath=/var/autohome.

18.2. Directory organization

Refer to directory organization under the real base directory for a detailed explanation of this topic.

autohome does support this kind of organization. The suboption used to specify the desired directory organization the level suboption, for instance: -o level=2.

18.3. Misc suboptions for autohome

The suboption skel can be used if the skeleton path is not the default value /etc/skel: -o skel=/some/other/dir.

The suboption noskel can be used with -o to indicate not to copy any skeleton files to the home directories when these are created.

18.4. Example

First, import your user accounts from a centralized database, for instance from LDAP.

Next, the autofs kernel module must be loaded into the Linux kernel. This can be done as described in autofs kernel module section.

If /home is to be used for home directories then /home will become the virtual directory; this is specified to autodir with the -d /home option.

Assuming that the autohome module is located in /usr/lib/autodir/autohome.so, this module can be loaded with autodir as -m /usr/lib/autodir/autohome.so. Note that the full path for the module is given.

The actual location of the real home directories is given with the realpath suboption. If it is /autohome, the location can be specified 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, initially the /home directory will be empty. Whether Autodir is working properly can be tested by changing directories to one of the home directories, as the root user or as the owner of the home directory.