Wednesday, May 18, 2011

Automounting your CIFS shares on OSX

So, say you have a NAS/Server exposing shares over CIFS (SMB), and you want your OSX based computer / media player PLEX (plexapp.com) to automatically mount your media share on boot...Lets go. Works on 10.5 and 10.6, untested on others.

Note in my testing I have found CIFS to be more reliable and faster for transfers, essential when you have multiple systems accessing media/files. I had performance issues with AFP especially listing large directories.

OSX has a nice, built in mechanism for auto mounting filesystems, re-mounting them if they drop, it's called autofs.

In order to mount your SMB/CIFS share (or any type for that matter) it is simply a case of updating your /etc/fstab file.

In the follow example replace the following with your details

<SERVER> The DNS or IP of your server, [ eg. "server.local" OR "192.168.1.50" ]
<SHARE> The name/path of the share on your server, [ e.g. "media" ] 
<USER> The username of the user to access the server share [ e.g. "john" ]
<PASS> The password of the user
<MOUNT> Where you want the share to be mounted [ e.g. "/Users/username/Media" ]

In Terminal, do the following

sudo nano /etc/fstab

Enter your password when requested...

<SERVER>:/<SHARE> <MOUNT> url automounted,url==cifs://<USER>:<PASS>@<SERVER>/<SHARE> 0 0

Save the file and exit, (press ctrl+x and answer yes to save)

Next you want to chmod your mount folder to ensure that you can access it, and the system can mount to it.

chmod 777 <mount>

Next, we want to restart the autofs service, so it knows of our new auto-mount

sudo automount -vc

It will return a list of mounts that it is automounting, and your new one should be in there. If you have any troubles, check the formatting of the command you a have placed in the /etc/fstab file, check your paths and user permissions on the server for the provided user.

No comments:

Post a Comment