How to Automount a CIFS/AFP Share on Mac

I set a Mac to be backed up by our TSM server. There was an external AFP share mounted at /Volumes/Data. I wanted to back up that share, too. The problem was that, for some reason, the share got unmounted from time to time. My first attempt at solving the problem was to write a shell script to mount the AFP share. Then, I scheduled it to run before the backup job. This was not helpful either, because the share still frequently got unmounted.

I then tried many different approaches and found that this one worked pretty well. The idea is to edit the /etc/fstab file to specify the mount information so the automount service can mount the share whenever it is being accessed. Here are the steps:

  1. Open Terminal application.
  2. Type sudo nano /etc/fstab to edit the file.
  3. Add this line.
    host_name:/share_name /Volumes/mount_name url automounted,url==afp://user_name:[email protected]_name/share_name 0 0
  4. Press Ctrl + x to save the file and exit out.
  5. Type automount -vc to restart automount.

If you want to mount a cifs share, just change afp to cifs. This is one example using cifs.

host_name:/share_name /Volumes/mount_name url automounted,url==cifs://user_name:[email protected]_name/share_name 0 0

Note that the host_name must resolve to the actual IP address of the host computer. You could modify /etc/hosts to add the host_name to it if the host_name cannot be resolved by the DNS server.

Be the first to comment

Leave a Reply

Social Widgets powered by

Advertisment ad adsense adlogger