Autofs is one of the features in Leopard that is currently going a bit unnoticed and under-appreciated. In Leopard, autofs is completely re-written and is multi-threaded. TIGER’s automounter was excruciatingly slow and inflexible w.r.t to its configuration. I felt none of those pains when I tried Leopard’s automount with my NFS shares. In this article, we are taking a look at Leopard’s autofs facility in depth from a unix system administrator’s perspective. Meaning that we won’t cover what autofs is, what is NFS, SMB etc. We think you are a very smart person and can actually teach us a thing or two about these things. What we will cover is the various configuration possibilities, tricks and gotchas in an effort to realize its full potential.
Although the unix guys may be most thankful for the improved support of NFS and autofs in Leopard. It is worth noting that autofs capabilities can be as easily utilized to manage all other kinds of file shares as well – NFS, AFP and SMB. So if you support Leopard in an enterprise environment, take full benefit of this new layer and manage all of your file systems with it. If you are looking for information about integrating Apple into your exsiting Unix/NFS environment, please read the article Integrating Mac OS X into Unix LDAP Environment with NFS Home Directories.
Rant: Even with Leopard, there is no support for Microsoft DFS. (grr….)
Autofs in Leopard
Autofs in Leopard consists of the following programs and daemons.
- autofsd runs automount, and then waits for network configuration change events and, when such an event occurs, re-runs automount to update the mounts to reflect the current automounter maps. It can also be signalled by automount_reread to run automount.
- automountd is a daemon that responds to requests from autofs to mount and unmount network filesystems, and to supply the contents of directories, based on the contents of automounter maps. The automountd is started on demand by launchd.
- automount is the actual mount manager. Manages the mounting and unmounting of remote resources using several map files and configuration files. The configuration files used are /etc/autofs.conf and /etc/auto_master.
- The man pages for autofsd refer to a command called
automount_rereadthat can trigger a network change event for autofs. However, there is no additional documentation in Leopard on that command and the command itself does not exist. May be we are looking at a placeholder for a future command.
Tip: Know that
automountdwith specific parameters to under take the mount/unmount actions. (autofsd->automount->automount)
Configuration and Map files
The global configuration files and the standard map files that autofs uses are
/etc/autofs.conf file is used to set both automount and automountd parameters.
/etc/auto_master is the master map file for automounter. Within that file, direct and indirect maps (or a directory service pointer) may be specified. The man pages for these files are located here.
Tip: For home networks, I would change AUTOMOUNT_TIMEOUT value to 5 minutes (300) in
/etc/autofs.conf. For corporate networks, depending upon your NFS environment and network, you may chose to set the value to 1 hr (3600)
Learning by Example
Let’s go through the steps of configuring Leopard’s autofs to serve and manage a few file shares. Along the way, we’ll uncover the ways to configure, change a few config options and see if this facility actually works. I am using my trusty Infrant ReadyNAS appliance for my tests.
In order to aid in our testing, let us turn up the logging for a short while. Edit the file
/etc/autofs.conf file, uncomment the following two options and set them to TRUE.
Mounting Home Areas with auto_home, indirect maps and wildcards
In this example, we will try to mount home areas that are remotely hosted on a NFS server using automount’s indirect maps. If you have used autofs in linux, chances are you have already done this a million times.
- Make sure that the /etc/auto_master file includes this line.
/home auto_home -nobrowse
In this example, we are configuring
/hometo be the mount point where we will mount all of the home areas. The map file /etc/auto_home will be used to specify the individual mappings. The
-nobrowseoption is used to prevent the listing of entries when there are a large number of them present. For more information on this and the auto_master file, man page to the rescue!
- Edit the file
/etc/auto_home(or create one if not present) and add an entry for the home area. Here’s an example:
This will result in the mounting of
192.168.1.5:/c/Localwhen the home area
/home/foobaris requested. Quite simple.
- Load the configuration file by issuing the command
rajeev-osx% sudo automount -vc Password: automount: /net updated automount: /home updated automount: no unmounts
- CD-ing time!
rajeev-osx% cd /home/foobar rajeev-osx% df -h . Filesystem Size Used Avail Capacity Mounted on 192.168.1.5:/c/Local 667Gi 172Gi 495Gi 26% /home/foobar
So we now know it works!
- Undocumented feature – Wildcards do work! Just like a traditional unix autofs implementation, auto_home in Leopard also support wildcards. Wildcards are GREAT when you are dealing with a large number of home areas and the user’s home directory name matches with the username, a common practice. Imagine your life if you have 1000 users and you’ll have to maintain those individual entries in auto_home. Ouch!! Using wildcards, all you need is 1 entry in the auto_home file:
In this case, the username is passed is as the keyword and the nfs server path is dynamically determined and used for mounting. For example, when I do a
cd /home/rajeev, the keyword
rajeevis passed as the key and the nfs path is automatically determined as
I have added this line to my auto_home file and like before, issued the
command to re-read the map file.
rajeev-osx% sudo automount -vc Password: automount: /net updated automount: /home updated automount: no unmounts rajeev-osx% cd /home/rajeev rajeev-osx% df -h . Filesystem Size Used Avail Capacity Mounted on 192.168.1.5:/c/rajeev 667Gi 172Gi 495Gi 26% /home/rajeev
Direct Maps and Directory Utility
Direct maps associate file system locations to directories. They are used to explicitly mount directories from the NFS servers on to a mount point on a client. An example direct map might look like the following:
/usr/local -ro \ /bin 192.168.1.5:/c/Local/bin\ /share 192.168.1.5:/c/Local/share \ /src 192.168.1.5:/c/Local/src
Why do I need to do that ? Because unlike indirect maps, direct maps allow for individual directories in a mount point to act as mount points and retains their visibility. This means,
- I can have
/usr/local/bin, /usr/local/share, /usr/local/srcall point to various NFS server path. With indirect maps. Once I mount /usr/local/ from an NFS server, I lose the ability to mount its sub-entries from elsewhere
- I can have a
/usr/local/manthat is local to the client as well!
In this regard, Leopard’s autofs implementation is already superior to any Linux autofs implementation I have come across. Both Solaris and (now) Leopard support direct maps. There has been talk to incorporating support for direct maps in linux autofs but I have not seen or heard of any progress on it.
Direct Maps are specified with the following line in the
The reserved keyword
/- specifies that the map is a direct map. According to the auto_master man page, the contents for this map is generated from all entries in /etc/fstab that do not have an “net” option. There is also an another way to enter direct map entries, via the Directory Utility. This utility stores the entries not in the /etc/fstab but in the local directory service. In Leopard, these entries are located in
/var/db/dslocal/nodes/Default/mounts as XML files.
Adding entries using Directory Utility:
- Bring up Directory Utility (/Applications/Utilities)
- Click “Show Advanced Settings”. This will bring up a menu on top
- Click “Mounts”
- Click the lock to make the changes
- Click “+” to add your entries
- You can include advanced mount parameters. I believe that the mount options from the mount_nfs man page can be used here. Make sure to not specify the “net” option, since we are configuring a direct map entry.
/etc/fstaband add entries in the following format:
server:/path mountpoint fstype options rw 0 0
- In our example, we will add the following entries
192.168.1.5:/c/Local /usr/local/local nfs rw 0 0 192.168.1.5:/c/man /usr/local/doc nfs ro 0 0
Note that I have specified
/usr/local/localas a read-writable fs and
/usr/local/docas a read-only file system.
Now we see the direct maps in action.
sh-3.2# df Filesystem 512-blocks Used Available Capacity Mounted on /dev/disk0s2 233769824 100202568 133055256 43% / devfs 212 212 0 100% /dev fdesc 2 2 0 100% /dev map -hosts 0 0 0 100% /net map auto_home 0 0 0 100% /home map -static 0 0 0 100% /usr/local/local map -static 0 0 0 100% /usr/local/doc
and some tests..
sh-3.2# cd /usr/local/local sh-3.2# df -h . Filesystem Size Used Avail Capacity Mounted on 192.168.1.5:/c/Local 667Gi 172Gi 495Gi 26% /usr/local/local sh-3.2# cd /usr/local/doc sh-3.2# df -h . Filesystem Size Used Avail Capacity Mounted on 192.168.1.5:/c/man 667Gi 172Gi 495Gi 26% /usr/local/doc sh-3.2# touch /usr/local/local/foo sh-3.2# ls -l /usr/local/local/foo; rm /usr/local/local/foo -rw-r--r-- 1 65534 65534 0 Nov 22 22:17 /usr/local/local/foo sh-3.2# touch /usr/local/doc/foo touch: /usr/local/doc/foo: Read-only file system
In the next part of this article, I will cover the use of the “net” option and using automount for AFP and SMB.