Howto: Configure your Mac to automatically mount an SMB share as needed


 

Background: I have come across two methods that allow you to automatically mount SMB/Windows file systems over the the network from your Mac system.

This tutorial will explain how to configure your mac such that one or more SMB file shares are mounted as needed -- such that every time you access the mount point, it will automatically mount a directory from the server. The other method will be covered in another tutorial.

This has been tested using the UWO internal wired networking, on a Mac running MacOS 10.6.3

Please Note This method requires that you store your SMB password in plain text in a file on your mac.

We STRONGLY recommend against using this method, ESPECIALLY if the system is a laptop.
If your mac is compromised, so is the security of our Research Network.

 


 

Instructions:

First you need to create a mountpoint -- an empty folder on your local mac, where you want the SMB fileshare to be located. The SMB filesystem will be mounted "on top of" that folder -- just like a Unix mountpoint, for those of you with a Unix background. For example, I have created the folder "RENT" in my home directory, which I will use to mount my Unix home directory.

Next, open a Terminal window. The rest of these instructions are all done in a terminal window. You need to be familiar with using a terminal window and a text editor. I will be using the "vi" editor in these example instructions.

	$ sudo vi /etc/auto_master
Add the line "/- auto_smb" to that file.
	$ sudo touch /etc/auto_smb
	$ sudo vi /etc/auto_smb
	$ sudo chmod 600 /etc/auto_smb
This creates the file /etc/auto_smb, and makes it owned by root:wheel and only readable by root.

Now, in that file you enter one line for each SMB filesystem that you want to automatically mount. The lines need to look like this:

	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 have used this entry to mount my home directory from Arion:

	/Users/amulder/RENT -fstype=smbfs ://amulder:XXXXX@arion.csd.uwo.ca/HOMES/amulder

Once you have those files set up you could either reboot your computer or try running the command: sudo automount -vc
(Supposedly rebooting is considered more of a sure thing. Sometimes just running the automount command does not work.)

Common Problems:

If you see an error such as "No locks available" or "Disc quota exceeded", you may have a password or username problem. Doublecheck your entry in /etc/auto_smb for mistakes or typos.

When you run the "sudo automount -vc command, you should see output similar to this:

	$ sudo automount -vc
	automount: /net updated 
	automount: /home updated 
	automount: /Users/amulder/RENT updated 
	automount: no unmounts 

Another thing to keep in mind is that the files DO NOT show up until you try to access them.

I also encountered a situation during testing where the Finder refused to open the mountpoint. Relaunching the finder (using "Force Quit" under the Apple Menu) cleared that up quickly.


End of Instructions.
27/Apr/2010 -- Art Mulder -- UWO CSD HowTo articles

Reference: Original Instructions from macosxhints.com