In this multi-part series, we are taking a detailed look at Leopard’s autofs facility. In Part I, we have covered the basic setup of autofs in Leopard, the configuration filenames and locations, automounting home directories with nfs, direct maps and Directory Utility. In this part, we will cover the remaining special features of autofs including -fstab, -hosts and -null type of maps. Lastly, we will also find out how we can use autofs for not just NFS but also for SMB /CIFS and AFP file shares!
Special Maps: -fstab option
This is a special type of map in Leopard autofs. This map is triggered in autofs using the following like:
/Network/Servers -fstab
Note that the mount point /Network/Servers is default in Leopard. This allows for file shares to be visible via Finder. The key values for this map is the hostname of the nfs server. The values are all the mounts that are exported by that server with the net option. Similar to direct maps, there are two ways to provide those entries to autofs. The BSD way is to edit the file /etc/fstab and add entries with the net option. The GUI/OSX way is to use Directory Utility and manage entries. Recall that Directory Utility stores its entries as XML files in /var/db/dslocal/nodes/Default/mounts.In addition to the net option, if you have large number of servers and mounts present, the use of resvport mount option is also recommended. For BSD files, the option is resvport and for Directory Utility, the option is -P.
- Adding -fstab entries, BSD Style
192.168.1.5:/c/man dummy nfs net 0 0
Note that the mount point here is specified as “dummy”. This is because the fstab entry requires a mount point value. However, this map type does not use the mount point from the fstab entry at all. The mount point is specified in the auto_master file itself (/Network/Servers). So any value can be specified here (say, boo)
sh-3.2# automount -vc automount: /net updated automount: /home updated automount: /Network/Servers updated automount: /usr/local/local updated automount: no unmounts sh-3.2# cd /Network/Servers/ sh-3.2# ls 192.168.1.5 sh-3.2# cd 192.168.1.5/ sh-3.2# cd c/man/ sh-3.2# df -h . Filesystem Size Used Avail Capacity Mounted on 192.168.1.5:/c/man 667Gi 172Gi 495Gi 26% /Network/Servers/192.168.1.5/c/man
In the Finder sidebar, you should file a clickable globe titled “All”. Click on that and navigate to the mount point in Finder!. If you do not find it in Finder, make sure to check your Finder Preferences and check the box for viewing the Connected servers.
- Adding -fstab entries, OSX/GUI Style
- Bring up Directory Utility (/Applications/Utilities/Directory Utility)
- Click “Show Advanced Settings”.
- Click “Mounts”
- Click the lock to make the changes
- Click “+” to add an entry
- Add you entry, expand the mount parameters box and enter net in the options. If you have other options to add, add them as well, comma-separated.
At this point, you can either wait for some time for the autofs to detect the change and reload the maps or run the automount -cv command to load the changes.
Special Maps: -hosts option
This is another special map for autofs and is widely used in the Linux world as well. Traditionally, this map would be mounted on the mount point /net. This map simply uses the hostname as the key and uses all of the mounts exported by that server as its entries. It is a quick way to provide file shares from all of your NFS servers. The file share path is mount_point/hostname/nfs/server/path.
/net -hosts -nobrowse,nosuid
Going back to our nfs server, let us examine what NFS shares are being exported
sh-3.2# showmount -e 192.168.1.5 Exports list on 192.168.1.5: /c/rajeev * /c/Local * /c/man *
To access these shares, simply traverse to /net/192.168.1.5/c/rajeev, for example. It is also advised that with this option, the use of -nobrowse option is recommended as the /net option can be very chatty otherwise.
Special Maps: -null option
This map has no entries. It is used to disable entries that occur later in the auto_master file. For example:
/shared -null +auto_master
This will disable any /shared entries coming from the Directory Services as a result of the +auto_master
Using Autofs with CIFS and AFP
As mentioned in the beginning of Part I, while autofs is widely used to manage NFS mounts, autofs can also be used for the management of SMB/CIFS and AFP shares. Unlike NFS, SMB/CIFS and AFP shares can be managed only using the BSD files and not using the Directory Utility. For a GUI method, just hit Go->Connect to Server and enter the SMB path in the format smb://username:password@servername/path/to/smb/share or afp://username:password@servername/path/to/afp/share
SMB/CIFS with Indirect Maps
In this example, we will use the mount point /smb and specify a indirect map auto_smb for our entries.
/smb auto_smb
In /etc/auto_smb, the SMB/CIFS mount entries need to be in the following format:
key -fstype=smbfs ://username:password@servername/sharepath
For example, one of my entry is as follows
Documents -fstype=smbfs ://Documents:myverysecretpassword@192.168.1.5/Documents
Since this file contains the username and password for the CIFS shares, make sure that this file is owned by root (chown root:root /etc/auto_smb) and read permissions restricted to root (chmod 600 /etc/auto_smb). After the obligatory reloading of automounter, we verify that we can indeed mount it!
//Documents@192.168.1.5/Documents 90Gi 15Gi 75Gi 17% /smb/Documents
AFP with Indirect Maps
The only difference between SMB/CIFS and AFP is the map entry format. For AFP, the format in the map file is
key -fstype=afp afp://username:password@servername/sharepath
As an example, if we were to mount the above Documents/ share using AFP, the map entry would look like this:
Documents -fstype=afp afp://Documents:myverysecretpassword@192.168.1.5/Documents
That’s it! The rest of the mounting process is the same.
SMB/CIFS and AFP shares with Direct maps, -fstab
SMB/CIFS and AFP shares can be used in Direct maps and special maps like -fstab just like NFS shares. The format for the SMB/CIFS and AFP shares that need to be followed in the /etc/fstab is different from the NFS format.
- An SMB/CIFS share is specified as
servername/path mount_point url net,automounted,url==cifs://username:password@server/path 0 0
Note that the net option is specified for -fstab type of maps and is not specified for direct maps.
- An AFP share is specified as
servername/path mount_point url net,automounted,url==afp://username:password@server/path 0 0
The note about the net option applies to AFP as well.
Conclusions
The verdict is that Leopard’s autofs implementation is on par with the Unix autofs implementation. Personally, I think it is better than Linux implementation, just because of the support of the direct maps. There is room for improvement in terms of automatically showing the mounted volumes in the Finder sidebar (which would be cool) and to remove the dependency of /Network/Servers for Finder visibility. But this is a great improvement over TIGER’s automounter and we’ll take it!








Hello Rajeev,
Sorry, if you wind up getting this twice as I wasn’t sure if it had been sent correctly.
I was wondering, given your extensive expertise and knowledge with Autofs on Leopard, if it’s possible you could help clarify something for me ?
It’s a simple question, really.
How does one get rid of sub-directories created in /net ?
Somehow, I’ve accidentally managed to create these sub-directories…
/net/localhost
/net/broadcasthost
….after running the following (on Mac OS X 10.5.8 (client version)) as I was trying to create a new user….
‘dscl . -create /Users/aUserShortName NFSHomeDirectory /Local/Users/aUserShortName’
I simply wished to created a standard user for for this Mac in the out of the box /Users directory. i.e.- In the local directory services database with no intended current or future relationship with servers whatsoever, period. When the user’s home directory didn’t appear in /Users I ran this (perhaps causing more damage)…
‘dscl . -create /Users/aUserShortName HomeDirectory /Local/Users/aUserShortName’
After running the above commands was the point which I discovered the undesired ‘/net/localhost’ and ‘/net/broadcasthost’ directories.
As a site note, I probably should of ran this instead given that it’s just a standard end user Mac OS X (Client) type machine (not used in a server related environment)…
‘dscl . -create /Users/aUserShortName NFSHomeDirectory /Users/aUserShortName’
I see from one of your articles that there’s a special map/ -null option (‘/users -null’) to disable entries after it the auto_master file. However, upon examining my backup volumes they don’t have that set (and these don’t have the annoying ‘/net’ sub-directories). So, some configuration must of been unintentionally turned on elsewhere.
As well, I’ve read through Apple’s white paper on this (http://images.apple.com/business/docs/Autofs.pdf) and numerous other articles/docs/posts related to Leopard’s Directory Services. While there’s considerable info on how to enable and configure these services there’s little on how to turn them off and make ‘/net/*’ directories completely go away once created.
Thanks,
-A
@jeckyll
You should be able to mount it using CIFS protocol.
Thanks for the great Tutorial!
I wanna map a smb share of a server here at work to a directory in my user directory. Is there a way to do this? Thanks
I forgot: you will of course probably need to supply username and password in the URL for the RecordName attribute, so it should be “url=smb://username:password@server.dns.name.or.ip/path_to_share.”
I find there is a more Mac-style way on Leopard to create SMB or AFP automounts than editing config files in /etc. What I do is create a new record using Workgroup Manager in the Mounts node of the local directory (/Local/Default). You have to create these attributes: RecordName, VFSLinkDir, and VFSType. For RecordName, use the URL to your SMB share, i.e. “url=smb://server.dns.name.or.ip/path_to_share”, for the value. VFSLinkDir should be the local path to the mount point, i.e. “/Network/sharename.” VFSType should be “smb” or “afp” as needed. This creates an entry in the local directory (dslocal) that is (in my opinion) more easily managed than files in /etc.
Hi Guys.
I am seeing an interesting behavior with my Mac os leopard setup. When i connect resources on my nfs mount through finder i get permission errors because of group permisions, files i own work just fine.
What is strange is that from the terminal i can access and edit or delete these same resoures just fine. But when i try and edit a file in finder it just wont work.
Any ideas? I also have the machine hooked up to ldap.
This sounds great but reading this http://www.stress-free.co.nz/automounting_samba_shares_in_leopard
made me a little uneasy.
Quote: “After a few weeks of use I have found the automount technique described here is a little unreliable not only from the perspective of keeping the mount point active but also for maintaining the correct file permissions.”
Is automounting SMB sharees really adviseable in a production environment?
@JB
Short answer to your question – you can’t..
Not so long answer:
As you know, /mnt or /smb are unix mount points and Finder does not seem to recognize and interact with them at those junctions..
When setting up the indirect map for cifs (the /smb auto_smb), how do I get that directory to show up in the finder off the root of the drive? As soon as automount runs, the directory vanishes out of finder and the only way I have to access the share is to drill through the network/servers/server/share that I used to connect the automount. the only other way to get in is to go to the command line and go to /smb/.
@Adam
I see sshfs as an addendum/compliment to nfs. Having said that, I also have not tried macFuse yet – have you ?
Can Leopard’s autofs be setup to work with macFUSE and sshfs mounts?
@Mo
URL is the keyword for the fstab entry.
So for example
Servername = myserver
path = /vol/homes/jdoe
mountpoint = /home/jdoe
username = jdoe
password = jdoelovesmac
then the entry would be
myserver:/vol/homes/jdoe /home/jdoe url net,automounted,url==afp://jdoe:jdoelovesmac@myserver:/vol/homes/jdoe 0 0HTH
I am confused, what does “url” signify in the afp/-fstab entry
“servername/path mount_point url net,automounted,url==afp://username:password@server/path 0 0″. If you could provide an actual sample/example for that section it would be very very helpful.
[...] the next part of this article, I will cover the use of the “net” option and using automount for AFP [...]