Linux to Mac
Introduction to Autofs in Mac OS X
- 2009.07.01 - Tip Jar
Popularity: ![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
OS X uses an autofs code stack based on Sun's Solaris version of Unix. Many of the advanced features are not documented very well, and this can be an issue unless you are familiar with Solaris. I was not and had to do quite a bit of digging.
Autofs is often used in enterprise environments to set up network-based home directories and other network mounts for users at login. It can also dynamically mount network shares on access.
OS X auto_master and auto_home
The /etc/auto_master file controls the auto-mounted Network File System (NFS) file systems. If you are going to mount NFS volumes from a Linux server, there is one gotcha that I covered in an earlier blog post.
The auto_master defines all "maps" which are collections of automounts related by mount point and organized in one file (or directory service entry). Here is what the default file looks like on my Mac:
# # Automounter master map # +auto_master # Use directory service /net -hosts -nobrowse,nosuid /home auto_home -nobrowse /Network/Servers -fstab /- -static
The plus (+) sign in front of the auto_master entry tells OS X to look in the directory service (Open Directory, LDAP, etc.) for an automount record and use it if found.
Notice the /home entry is set to auto_home, and because it is not a full path, it is assumed to be /etc/auto_home. It is an example of an indirect map. The mount point in the local directory is defined, but the remote mounts are defined in the /etc/auto_home map file. Network users who login to the local machine will have their home directories mounted in /home according to the details in /etc/auto_home.
Here is the default /etc/auto_home file:
# # Automounter map for /home # +auto_home # Use directory service
Once again, we see the plus sign telling OS X to look for an auto_home record in the directory service. No further details are defined.
The last two lines in auto_master handle NFS mounts defined in the /etc/fstab file, the common file system mount table in Linux and other Unix flavors. The /etc/fstab file is deprecated in OS X and not recommended.
Applying changes to autofs
The automount process will not detect changes made to auto_master or other map files unless you tell it. This command tells the process to read all map files again:
sudo automount -vc
Autofs wildcards
Wildcards can be used in mount map files to allow directory substitution. For example, if you had this defined in auto_master:
/opt auto_public
And this defined in /etc/auto_public:
* nfs.mydomain.com:/public/&
Then, when /opt/bin was accessed, nfs.mydomain.com:/public/bin would be mounted on /opt/bin. The same would apply for any subdirectory accessed under /opt.
Other Map Types
OS X autofs supports direct maps, where the local mount points are defined inside the mount map file, and indirect maps, where the local mount point is defined in auto_master. The wildcard example above is an indirect map. There are also executable maps where the mount map file is actually an executable shell script that returns the names of the mount points within the trigger folder. Exploring executable maps is left as an exercise for the reader. Finally, you can define static maps in /etc/fstab or in the Directory Utility Mounts tab.
Other file system types
All of the examples shown use the NFS file system. OS X autofs can also handle Apple File System (AFP) and Microsoft Server Message Block (SMB) file systems.
To use these file systems, add the -fstype=afp and
-fstype=smbfs options when defining the remote mount points.
(Note: You cannot use smbfs for remote home directories unless you are
using the Microsoft Active Directory service plugin.)
Join us on Facebook, follow us on Twitter, use our Google+ page, or read our RSS news feed
Keith Winston is a recent Mac convert after five years of Linux on the desktop. He also writes for Linux.com and created CommandLineMac to focus on the Unix-y power of the Mac. If you find Keith's articles helpful, please consider making a donation to his tip jar.
Recent Linux to Mac Columns
- Apple's launchd Is Anti-Unix, 2010.07.13. Unix prefers programs that do one thing very well, but Apple's launchd takes the opposite approach.
- Automount OS X Home Directories Using OpenLDAP and Linux, 2009.09.28. It's possible to get an OS X Mac to automatically mount a Linux server using OpenLDAP. The tricky part is finding all the steps needed to make it work.
- Automating FTP on the Mac, 2009.03.04. There's no shortage of GUI FTP programs, but using the Terminal gives you tools to automate file transfer sessions.
- More in the Linux to Mac index.
Links for the Day
- Mac of the Day: Power Mac 7500, introduced 1995.08.08. This workhorse introduced a new desktop case and CPU daughter cards.
- June 19 in LEM history: 00: Mac software not 'as pathetic as it could be' - 01: Hate Windows? Get a Mac - Little payments, big business - 02: Undoing years of Mac evangelism? - 03: Back on the low-end TiBook - 06: Pimping my PowerBook G4 - 07: Safari for Windows not a slam dunk success - 08: What about the iPod touch? - Falling for the Sony Alpha α200
- Support Low End Mac
Recent Content on Low End Mac
- World Book Encyclopedia 2012 DVD, Tommy Thomas, Reviews, 2013.03.05. "You may be asking yourself, in an age of Wikipedia and instant information, is World Book still relevant?"
- Vintage Computer Festival SouthEast, April 20-21, 2013, Simon Royal, Mac Spectrum, 2013.02.25. Old Apple gear and old PCs.
- iMessage: The Ultimate Messaging Service?, Simon Royal, Mac Spectrum, 2013.02.21. In most ways, Apple's iMessage is far superior to BlackBerry Messenger.
- More links in our archive.
Recent Deals
- Best Mac mini Deals
- Best 13" MacBook Pro Deals
- Best Intel iMac Deals
- Best iPod touch Deals
- Best iPhone Deals
- Best iPod nano Deals
- Best iPod classic Deals
- Best Apple TV Prices
- More deals in our archive.
About LEM Support Usage Privacy Contact
FollowLow End Mac on Twitter
Join Low End Macon Facebook
Low End Mac Reader Specials
Favorite Sites
MacSurfer
Cult of Mac
Shrine of Apple
MacInTouch
MyAppleMenu
InfoMac
The Mac Observer
Accelerate Your Mac
RetroMacCast
PB Central
MacWindows
The Vintage Mac Museum
Deal Brothers
DealMac
Mac2Sell
Mac Driver Museum
JAG's House
System 6 Heaven
System 7 Today
the pickle's Low-End Mac FAQ
Affiliates
Amazon.com
The iTunes Store
PC Connection Express
Macgo Blu-ray Player
Parallels Desktop for Mac
eBay

