Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Automount Samba (Windows) shares as needed Network
Snow Leopard only hintHere's a way of mounting Samba shares in Snow Leopard that does not depend on the login process. This method auto-mounts a share when it is accessed. You need to have an administrator password to edit and create the needed files. First, edit /etc/auto_master (as root) and add a line:
/-     auto_smb
I use the free version of TextWrangler for this; it will prompt you for your admin password. This tells autofs to look in the file /etc/auto_smb for the mount info. The /- means the the full mount path will be specified in auto_smb.

Next, create a file called /etc/auto_smb which is owned by root:wheel. One way to do this is to type the following command in Terminal:
sudo touch /etc/auto_smb
Now edit this new file to put the share info into it.

Each row you add has the following format. Note that there is a space between smbfs and the colon.
mountpath -fstype=smbfs ://user:password@server/sharedirectory
mountpath is the path on the local file system where the share will be mounted. user:password is the username and password needed to access the Samba share. server is the Samba server name or address. sharedirectory is the directory on the Samba server that will be mounted. For example, I use these two lines:
/users/gordon/nas/family -fstype=smbfs ://gordon:XXXX@mynas/buchanan
/users/marcy/nas/family -fstype=smbfs ://gordon:XXXX@mynas/buchanan
This will create shares under the nas directory in the home directories for users gordon and marcy. The nas directories must be manually created by you; the automount process will automatically create the family directory.

To tell the system to use the new automount info, you can reboot. It should also be possible to run the following command, but I've found that it doesn't always work correctly.
sudo automount -vc
To access the share, just go to the mountpath; in my example, that's the directory /users/gordon/nas/family. The share will automatically be mounted.

This works great with iTunes. I have my library stored on the Samba server, and when I open iTunes, the share is automatically mounted and my music is available. For me, this works much better than what I had previously set up, which was mounting the server via a login process. Sometimes my share would get disconnected, for whatever reason, and then when I launched iTunes, I would get the message that the music library could not be found.
    •    
  • Currently 3.14 / 5
  You rated: 2 / 5 (29 votes cast)
 
[63,745 views]  

10.6: Automount Samba (Windows) shares as needed | 16 comments | Create New Account
Click here to return to the '10.6: Automount Samba (Windows) shares as needed' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Automount Samba (Windows) shares as needed
Authored by: quaker120 on Feb 05, '10 09:49:11AM

When I try this I get a permission error, "The folder <name> can't be opened because you donít have permission to see its contents."



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: gordonlbuchanan on Feb 06, '10 08:25:03AM

I assume you mean that you get a permissions error on the share folder i,e, if the mount point is /users/gordon/shares and the share name is mydocs, then you get the error on /users/gordon/shares/mydocs. Is that right? Do you have the correct userid and password for the share? Did you try rebooting after creating and editing the automount map file?



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: quaker120 on Feb 09, '10 10:20:14AM

Yes, had all that in place & rebooted.

I finally solved it by setting the permissions on my local folder (/Users/myname/share) to 777, now it works.

Thanks!



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: CG1 on Nov 11, '10 01:04:13PM

I found out that you should create the full path yourself, for instance not just /Users/<name>/shares/ but also /Users/<name>/shares/mountpoint

Otherwise, you will end up with a mount point that has root access only.



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: mr_yellow on Feb 05, '10 11:48:41AM

Is there a way to not hardcode credentials into the automount list? ie. use OSX's keychain?



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: gordonlbuchanan on Feb 06, '10 08:26:48AM

Not that I know of. But the map file does require an admin password to access it, so it is somewhat protected.



[ Reply to This | # ]
Works, fixes annoying firewall popups too!
Authored by: yarnmitch on Feb 05, '10 12:33:09PM
Thanks for the tip. This auto-mount method happens to stop the annoying firewall allow/deny pop ups that seem to occur when I have a Linux samba share mounted via Finder, and use a file open/save dialog from pretty much any app. (see Annoying Firewall Allow / Deny Dialog @ discussions.apple.com)
Edited on Feb 05, '10 12:45:26PM by yarnmitch


[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: gordonlbuchanan on Feb 06, '10 08:30:51AM

oops ... there is a little bug in the original post. It should say:

To access the share, just go to the mountpath; in my example, that's the directory /users/gordon/nas/family. The share will automatically be mounted.



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: robg on Feb 06, '10 08:10:36PM

The hint has been edited now.

-rob.



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: MrPaul on Feb 07, '10 08:58:12AM

I'm getting an interesting error. Neither machine is using quotas. Note that I haven't rebooted yet.

macbook-pro:nas pthomas$ cd htpc
-bash: cd: htpc: Disc quota exceeded



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: invictus26 on Mar 04, '10 10:39:51PM

I tried to set this up several times, but the folders in my "nas" directory are never created, and the shares won't automount. There doesn't seem to be any error. I've tried it a few times restarting each time. Any help would be really appreciated



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: zarac on May 02, '10 10:31:40AM

the same thing happens to me too, but i figured out that the directory actually is there, only hidden.
if i go to the mount point by using finder's "go to folder" and type the path manually, it opens fine.
same thing if i use terminal.
can anyone confirm this?



[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: zeusr on May 24, '10 01:54:16PM
Finally got this to work via AFP on 10.6.3. Here are my settings: In the /etc/auto_master file, I have the line
/- auto_afp -nosuid
and the entry in my auto_afp looks like
/Users/me/Movies/nas_stuff -fstype=afp afp://username:plaintextpassword@nas.local/directory
I didn't really have time to verify, but it looks like the 'afp' at the beginning of the URL portion is important! I'm using this to get my iTunes TV Shows and Movies for my laptop as the HD content was getting to be a bit much for my poor little 250GB hdd...

[ Reply to This | # ]
10.6: Automount Samba (Windows) shares as needed
Authored by: xylo on Nov 22, '10 10:31:19AM
Hi,

If you have not administrator permissions you can also use AutomountMaker tool that is more flexible !
( Even if you are administrator ;-)

JM Marino

AutomountMaker Developer.



[ Reply to This | # ]
make the mount visible in finder on login
Authored by: Caelum on Jul 31, '12 05:26:41PM

One problem with this hint is that your mount doesn't show up in finder until you open the directory with go or cd in terminal.

The way I fixed that is with a crontab.

Type this in Terminal:

crontab -e

that will use vim, if you want to use a simpler editor type this instead:

EDITOR=nano crontab -e

Now add this line to the file:

@reboot cd /path/to/mount

Now when you reboot the mount will be visible in finder immediately!



[ Reply to This | # ]
make the mount visible in finder on login
Authored by: Caelum on Mar 26, '14 02:56:18PM

The crontab method broke for me after the upgrade to Mavericks, but I found a different method that works, I will describe it here.

First, get the 'LaunchD Task Scheduler' app from the app store.

Make a new job, e.g. 'MountSMBShares'.

Write a bash script in your ~/bin that looks like this:

#!/bin/sh

sleep 10
cd ~/share1
cd ~/share2

etc.

make sure to chmod +x the bash script.

In the task scheduler job properties, put the path to the script as the command, e.g.

/Users/myuser/bin/automount_smb_shares

Uncheck all the options except "run at load and login" and "job enabled".

Save the job and reboot.

Your mounts should be available at log in now.



[ Reply to This | # ]