Tag Archives: CIFS

Mac: Auto-Mounting Network Shares

Admittedly, on the Mac I have always been a pure end-user only. So it is no surprise that I had never looked at Automator, which in hindsight is a real pity. When searching for an easy way to automatically mount CIFS shares from my NAS, I came across a post on Stackoverflow that suggested Automator as one possible way.

I have followed the steps there (adding “Get Specified Servers” first and then “Connect to Servers”) and it works like a charm. The only difference is that I did not use AFP as protocol but SMB. But syntax basically stays the same, so I ended up with


What I did differently, though, was the method to invoke my Automator-based application. Instead of adding it to my login items, I chose to have it executed by ControlPlane, whenever the latter detected a connection to my local network. This way, whenever I open my MacBook it automatically re-connects.

Linux Network Mounts for a Laptop

When you are running Linux (or any other Unix-like OS) on a mobile computer, you may have a bit of a problem with mounting shares from a server. On a normal PC with a fixed connection to the server, you would simply add the appropriate entries to /etc/fstab and have them mounted automatically during startup. But since I am not “always on”, this was not an option. So I added the “noauto” option to the entries in /etc/fstab, which effectively means that they get ignored during system startup. Of course I could later call mount /my/mountpoint manually for each entry. But this is cumbersome. So I went and wrote a small script (download here). For security reasons the extension of the script is set to .sh.txt instead of .sh, so you will need to rename it before execution.

There are a few conditions for the script to work:

  • Effectively the script will call “mount /my/mountpoint” for each relevant entry in /etc/fstab. All configuration details for the actual mount operation need to be provided in /etc/fstab. So before running the script, make sure those manual calls go through without problems.
  • For CIFS mounts the credentials should be provided using the “credentials” option from mount.cifs (see respective man page for details). Those can then be protected properly. And should there be several people using the system, they can maintain their passwords by themselves.
  • Currently there is connectivity check to the server(s). So you will get delays/errors when calling the script without a proper connection.

The script will detect whether a particular mount point is in use and skip the respective entry for mounting. The same goes for umount when the mount point is not used.

For CIFS mounts you will most likely need to call the script with sudo. At least on Fedora 12 I could not get mount.cifs to work for normal users, event with the SETUID bit set.

Mount Windows Share with Fedora 12

The file system type for the mount command has been changed from smbfs to cifs. So using “-t smbfs” will not work any more. Instead you need to enter something like this:

mount -t cifs -o username=user[,uid=500,gid=500] //machine/share[/path] /mountpoint

There seems to be a documentation bug in the man pages, because they still mention smbfs.