Less known Solaris Features: /export/home? /home? autofs?
History
The ever reoccuring question to me at customer sites relatively new to Solaris is: “Okay, on Linux i had my homedirectories at /home. Why are they at /export/home at Solaris?” This is an old hat for seasoned admins, but i get this question quite often. Well, the answer is relativly simple and it comes from the time when started to use NIS and NFS and it had something to to with our slogan “The network is the computer”, because it has to do with directories distributed in the network. Okay, we have to go 20 years in the past.
There was a time, long long ago, you worked at your workstation. The harddisk in your was big and it was a time when you didn´t need 200 Megabyte for your office package alone. So you and your working group used it for storing their data. But there were several workstations and even some big server for big computational tasks. The users wanted to share the data. Sun invented NFS to share the files between the systems. And as it was a tedious task to distribute all the useraccounts on all the systems, Sun invented NIS (later NIS+, but this is another story).
But the users didn´t want to mount their homedirectories on every system. They wanted to login to a system and work with their homedirectory on every system. They didn´t want to search it a seperate places depending if it was there own machine or a different one.
So Sun invented the automounter. It found it´s way into SunOS 4.0 in 1988. The automounter mounts directories into a system based on a ruleset. In Solaris 2.0 and later the automounter was implemented as a pseudo filesystem called autofs. autofs was developed to mount directories based on rules defined in so-called maps.
There are two of them. At first there is the /etc/auto_master
. To cite the Manual:
The auto_master map associates a directory with a map. The map is a master list that specifies all the maps that autofs should check
At a freshly installed system the file looks like this:
The file /etc/auto_home
is such a map referenced by the master map. To cite the manual again:
An indirect map uses a substitution value of a key to establish the association between a mount point on the client and a directory on the server. Indirect maps are useful for accessing specific file systems, such as home directories. The auto_home map is an example of an indirect map.
We will use this map later in this article.
The use case
Okay, an example. gandalf is the workstation of Waldorf and Statler. theoden is the workstation of Gonzo and Scooter. They have their homedirectories on their own workstation. Sometimes a team uses the workstations of the other teams and they on a gentleman agreement they allowed each other to do so. But they want to use their homedirectories on the system of the other team.
Prerequisites
At first we have to export the directories with the real homedirectories on both hosts via NFS.
At first on gandalf:
Now we repeat this steps on theoden:
Okay, it´s important that both hosts can resolv the hostname of the other system. I´ve added some lines to /etc/hosts
in my test installation:
Now i set to the homedirectory of both users to the /home
under the control of autofs:
[root@gandalf:~]$ usermod -d /home/statler statler
[root@gandalf:~]$ usermod -d /home/waldorf waldorf</code>
Now i create the the users for the other team. Now without the -m
-Switch and directly with the correct homedirectory. The homedirectories come from the other system. So we don´t have to create them:
[root@gandalf:~]$ useradd -u 2002 -d /home/gonzo gonzo
[root@gandalf:~]$ useradd -u 2003 -d /home/scooter scooter</code>
Now we switch to Theoden. We do almost the same on this system. We create the accounts for Waldorf and statler without creating a homedirectory. After this we create the local users together with their homedirectories and set them after this to autofs controlled /home
:
Configuring the automounter
Execute the following four commands on both hosts:
The ampersand is a variable. It stands for the key in the table. So gonzo theoden:/export/home/&
translates to theoden:/export/home/gonzo
. Now start the autofs on both hosts:
and
Testing the configuration
Okay, let´s login to theoden as User gonzo. Gonzo is a user with a homedirectory local to theoden:
Now we try waldorf on theoden. Waldorf dosn´t have it´s homedirectory on theoden, it´s on gandalf.
autofs has mounted the /export/home/waldorf
automatically to /home/waldorf
, the directory we used when we created the user.
Let´s crosscheck. We log into gandalf with the user waldorf. Now this user have a local homedir. It´s a local mount again.
Explanation for the seperated /home and /export/home
The explanation for the existence of /home
and /export/home
is really simple. I think you got it already. /export/home
is the directory where all the local directories are located. /home
is the playground for autofs to unify all homedirectories at a central place, where ever they are located.
The /net
directory
Did you ever wondered about the /net
in the root directory and it´s job? It´s an autofs controlled directory, too. Let´s assume you have an /tools/solaris
directory at theoden:
Share it via NFS
Now change to the other workstation. Look into the directory /net/theoden
:
[root@gandalf:/]$ cd /net/theoden
[root@gandalf:/net/theoden]$ ls
export tools
You will notice all the shared directories by theoden. Change into the tools/solaris
directory:
Neat isn´t it … it´s configured by default, when you start the autofs.
Do you want to learn more?
docs.sun.com -Solaris 10 System Administrator Collection
How Autofs Works
Task Overview for Autofs Administration</blockquote>