Automounting Samba shares in Leopard
Edit 15th November 2007: 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. This maybe addressed in future OSX 10.5 updates but for the time being using user-level mounts via Finder or Go -> Connect to Server is more reliable. To automatically mount a volume save the mount point as a Favorite (Go -> Connect to Server -> Add favorite) and then drag this favorite (stored in ~/Library/Favorites) to the Login Items under Account Preferences.

Apple have pleased a number of people by laying to rest the NetInfo Manager in OSX 10.5 'Leopard'. Many of the functions performed by this Registry-like tool have been incorporated into the far tidier Directory Utility tool. Unfortunately whilst this tool includes the ability to define automounted NFS shares the same capability is not provided for Samba. This is a pain because if you have a couple of Samba servers on the network that need to be connected all the time, a good example being a network share for iTunes music.
Fortunately all is not lost as we can still edit the automount configuration files directly so that our Samba shares are always accessible. To start with open up the Terminal application as an administrative user and then use sudo to create a bash shell.
sudo bash (enter)
You will be prompted to enter your administrator password at this point.
We will now create a file entitled auto.smb in the /etc/ directory to hold our server details.
pico /etc/auto.smb (enter)
In this file enter the following line (add more lines for extra servers/shares)
$Sharename -fstype=smbfs ://$Username:$Password@$Server/$Share
Where:
$Sharename = the name you want to give the mount point
$Username = the user to connect to the server as
$Password = password of the user
$Server = the name of the server (dns/wins entry)
$Share = the name of the share on the server
As this file stores the username and password to the server in plain text set the permissions of the file so that only the root user can read it.
chmod 600 /etc/auto.smb (enter)
Now edit the /etc/auto_master file and append the auto.smb record at the end of the file. The auto_master file controls all the automounts for the system, leave everything about this file alone except for the extra line at the end.
pico /etc/auto_master (enter)
#
# Automounter master map
#
+auto_master # Use directory service
/net -hosts -nobrowse,nosuid
/home auto_home -nobrowse
/Network/Servers -fstab
/- -static
/Users/Resources auto.smb
This will tell the automounter to mount the shares defined in the /etc/auto.smb file under the /Users/Resources directory. So for example if auto.smb defined a Music share we would end up with /Users/Resources/Music. Note: You do not have to use /Users/Resources.
With the configuration files in place it is now time to tell the automounter to refresh the settings. Exectute the following command:
automount -vc (enter)
If all goes well you should see the following output from this command:
automount: /net updated
automount: /home updated
automount: /Users/Resources updated
automount: no unmounts
Now you should be able to open the Finder and see a /Users/Resources directory that lists (and magically takes you to) all the network shares you have defined in the auto.smb file.
Hopefully this is only a temporary fix and Apple includes the option to mount Samba as well as NFS shares in Directory Utility. Technically it is not hard to do and the end result would be far tidier.
Space character in folder specification
I do not know if it is supported but...
If this is supported by Automount the syntax is most probably:
iTunes\ Music
Doesn't look like it is
Mounting folder comes up as network folder
I am not sure
I haven't use this method of mounting OSX volumes for a very long time, in fact I do not even know if it still works. The desktop may also be a special place given its prominence.
So...?
See the "edit" section at the top of this post
I use bookmarks and a startup item for mounting volumes automatically.
Apple Script Method
Could you go into a little
It was a while ago now but...
From memory I think the main problems centered around sleep. When systems would wake from sleep they would remount the volume but it would be under the OSX root permissions rather than the identified user.
Other times automount would mount the volume with the correct permissions but the symlink between the directory identified in auto_master and the actual mount point (buried deep in /var from memory) would not be created. As a result even though the volume was mounted users could not access anything via the Finder.
NOTE: This was way back in 10.5.0 days. Things may have changed since then. That being said I've found the Favourite/Finder combination to be the most reliable way of setting up automounts.
This is still a topic and an
This is still a topic and an issue. With 10.6.2 autofs still has the problem you described that after wake-up from sleep the directories are mounted but not accessible for ordinary users anymore.
Apples' autofs is quite different from Linux where the mounted directories are available to all users. I'm using a MacBook with two different user accounts, switching back and forth. I want to have one shared network drive accessible for both. Using autofs I need to have two mount-points, which is crazy. Every once in a while the directory of user A get's unintentionally mounted by user B and is not available for user A anymore. I don't see a way to prevent this.
With user level mounts by just using an alias to the shared drive in the start objects I'm also not very happy. Depending on whether user A or user B logs in first, the mount for user A is either /Volumes/share or /Volumes/share-1: Useless. Also remounting, e. g. after network disconnect, has to be done manually because many programs do not support the OSX mechanism of auto mounting an alias to a remote folder. They will just not "see" the folder but just an unknown file.
All in all the situation with OSX automounting SMB shares is really unsatisfying. Autofs still seems to be the better alternative if just the directory permission issues could be solved.
NFS maybe more appropriate
For what you describe (a system-level share) the NFS functionality in OSX maybe more appropriate. It seems Apple has targeted the SMB/CIFS functionality at single users, whereas their NFS functions only work across the entire system.
Unfortunately given your file server setup this may not be possible.
I found the easiest way to
Domain?
Neither the auto_master nor fstab method works in 10.5.1
Neither the auto_master nor fstab method works in 10.5.1. Both
produce “$Sharename” folder in either /Users/Resources (auto_master) or in
/Network/Servers/$Server (fstab). This folder is however empty.
Thanks/Mikael
Strange if true
That is a strange development if true.
I've moved away from using command line automount in favour of user-level favourites as it is proving to be far more reliable not only when it comes to keeping a volume mounted but also when it comes down to file permissions.
/etc/auto_master already has
/etc/auto_master already has this line:
/Network/Servers -fstab
which uses /etc/fstab to list shares that should be mounted in the /Network/Servers directory. so you can set up your smb automounts by changing only one file, /etc/fstab. the entries look like this (should be all one line):
$Server:/$Share x url net,automounted,url==cifs://$Username:$Password@$Server/$Share 0 0
the second entry, x, usually would mark the mount location in fstab. however, auto_master has overridden this to always be in /Network/Servers, so you can put anything there.
Correct but it has its own limitations (and risk)
/Network/Servers is not the most useful place to automount things because for many tasks it is a difficult place to navigate to in the Finder (something which is important for non-technical users). Consequently you would probably end up making a symlink somewhere in the Finder accessible filesystem back to /Network/Servers so the workload balances itself out.
I would also be wary of the /Network/Server -fstab just because it may be modified by an Apple update in the future. For example if you checkout /etc/fstab.hd you'll see this warning message:
IGNORE THIS FILE.
This file does nothing, contains no useful data, and might go away in
future releases. Do not depend on this file or its contents.
Whilst this is not /etc/fstab the fact that it doesn't exist is perhaps a sign that Apple is phasing out the use of /etc/fstab*.
Personally I like using an /etc/auto.smb file because it is something Apple won't change on me or depreciate the use of. Even if they do update the /etc/auto_master file in the future at least I know what to add to reestablish these mounts and I don't need to painstakingly recreate the mount details (server/username/password) themselves.
in leopard, you can fairly
in leopard, you can fairly easily get to /Network/Servers by clicking on 'All...' under the 'Shared' section of the sidebar. it seems to be an alias for /Network, because you'll find the Servers folder there. command-shift-k will also take you there.
granted, apple may change the system configuration around in a way that wipes out /etc/fstab, but it's no worse than what happened to all my mounts that were previously kept in Netinfo Manager =). there's no guarantee that they will keep using the same version of automount either, for that matter. i guess we'll just have to be ready to come up with a new solution every time there's a major release of OSX.
Fortunately automount is fairly standard
What is nice about 10.5 is that the automount functionality brings OSX inline with other operating systems such as FreeBSD. This makes a lot of sense as their previous in-house effort just didn't cut the mustard (beachballs, beachballs, beachballs). Hopefully if anything we see the automount GUI tools fleshed out so that we don't have to resort to the Terminal to get things done that should be easy. I mean since Windows 2000 (or longer) it has been possible to automatically mount a Windows network drive on reboot or network failure, why does Apple have to make it so hard?
previous automounts
If you have previous smb shares that you used netinfo to setup then where do they reside now that the upgrade has been done?
Chris
old automounts after update from tiger
They went here as xml files:
/var/db/dslocal/nodes/Default/mounts/
You need to be real root to access this directory (use sudo bash for this).
gone
i think they're gone. after i upgraded i couldn't find any trace of them. you're pretty much starting from scratch.
re: gone
mine stayed; i have no fstab file or auto.smb, i've no idea where its loading them from. any idea?
Not a clue
No idea but I wouldn't be surprised if they disappear in future OS updates.
I don't know as I never tried this
All of my Leopard 'upgrades' have been fresh installs mainly due to the fact I had made so many system tweaks in Tiger I wanted to start with a blank slate. I would guess that if you have performed an upgrade of Tiger and your configured mounts have not come through then they are probably still buried in the system but not being parsed by automount. The danger with these NetInfo configured automounts is that there is no longer a formal means of viewing or editing them which could lead to problems down the line if they do currently work.
What do I have to change If
What do I have to change If I want to mount this under Devices in finder?
Is it /Volumes that I need to use instead of /Users/Resources ?
Yes although be careful
Setting /Users/Resources to /Volumes will autmount under the /Volumes directory (where normal volumes are mounted) but I am not sure how the Finder will react to these mounts. I don't think the automounts will appear as traditional volumes and you cannot manually browse to the /Volumes directory in the Finder (you would need to use to Go -> Go to Folder... option).
Also I do not know how the system would react if you tried mounting a volume in the /Volumes directory that had the exact same name as the one defined in auto.smb. My guess is that the auto.smb mount point would be overridden. This would lead to quite a bit of confusion :-)
Just add a folder from the