Plex Forums: Howto automount AFP/SMB shares using autofs - Plex Forums

Jump to content

  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Howto automount AFP/SMB shares using autofs

#1 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 01:07 PM

Hi everybody,
I've read a couple of times on this forum about people trying to automatically mount there AFP/SMB shares to access their media. They use fancy Apple scripts or payed applications to do the work but still experience issues when the NAS reboots or the network drops. I think the Mac is widely underestimated here because he can do so much more and there is a very elegant solution available since 10.5 for that, called autofs.
True to the point people have been writing about this feature already on this forum you can find a nice post by puithove here. And there are of course a handful of guides on the net as well. In case you want to know all the details have a look at this nice guide by Rajeev (Part1 and Part2) or have a look at the official white paper by Apple here. A very comprehensive one can also be found here.
This looks all quite difficult and scary but just getting AFP/SMB shares to mount automatically upon access you just need to add one line to your /etc/fstab file. So I thought it might be about time to write a short in a nutshell howto to get more people to use this feature.
In principal this is a four step procedure so here we go:

  • So first of all we need to create mount points, i.e. the point in your file system you want to attach your shares to. For that I created a folder called 'Shares' in my home directory and added a subfolder 'Movies' to which I want to attach my Movies share from my NAS. I will use this as an example here but you can put those folders anywhere you like. The real power already becomes apparent here. This is not a share you automatically mount to your desktop. This is just a folder on your file system. Whenever you access that folder your Mac will access the share in the background. So the integration is seamless and no one working on the system or no program can tell the difference from a normal folder.
  • The next step requires editing the fstab config file situated in /etc/fstab. Fire up the Terminal and type
    sudo nano /etc/fstab
    if you don't like nano you can use any other text editor but then you are on your own. You will be prompted for your password and then nano opens the file. This file should be empty. Enter the following lines into the file. You need to replace YOUR_NAS, YOUR_SHARE, YOUR_LOGON, YOUR_PASS and /Users/simon/Shares/Movies with the name of your NAS, the name of your share on the NAS, your logon, your password and the path to your mount point (see step 1) respectively.
    #Mount AFP shares from YOUR_NAS
    
    YOUR_NAS:/YOUR_SHARE /Users/simon/Shares/Movies url automounted,url==afp://YOUR_LOGON:YOUR_PASS@YOUR_NAS/YOUR_SHARE 0 0

    for SMB shares this should look like this:
    #Mount SMB shares from YOUR_NAS
    
    YOUR_NAS:/YOUR_SHARE /Users/simon/Shares/Movies url automounted,url==cifs://YOUR_LOGON:YOUR_PASS@YOUR_NAS/YOUR_SHARE 0 0

    Type CTRL+O followed by RETURN to save the file and CTRL+X to exit nano.
  • Now you can reboot your Mac to make it active or even better you can just issue the command
    sudo automount -vc

    If everything was set up correctly you should get a reply similar to this:
    automount: /net updated
    automount: /home updated
    automount: /Users/simon/Shares/Movies mounted
    automount: no unmounts

    Now you can try to open your mount point folder and you should see the contents of your share in there. Neat ain't it :)
  • As the final step you can now add that folder as a source to Plex. Please don't forget to disable your previous automount solution as in Leopard you did have problems accessing the mount point when the share was already mounted on the desktop. I just tested this in Snow Leopard and there the limitation doesn't exist anymore. Then you are ready to go.

I have been using this set up for more then a year now and haven't had a single outage no matter how I restart my NAS or my Mac etc. Also hibernation of my NAS is not an issue as autofs disconnects if the share is not used and then re-connects if you need it. So my NAS is not suffering from insomnia in any way.
Have fun!
Poldi
3

#2 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 02 May 2010 - 03:33 PM

Hi Poldi,

First, thanks a lot for your effort! I've been tempted to do this for quite a while already, but it seemed a bit scary indeed.

Unfortunately, I cannot get it to work, probably because I'm missing an obvious point.

Editing fstab seems to go just fine, after that, running:
sudo automount -vc

returns the following:
automount: /net updated
automount: /home updated
automount: /Users/imac27/Desktop/Test mounted
automount: no unmounts


After running this command (i.e. sudo automount -vc) the folder icon for Test (in Desktop) changes into a blank alias icon. When I try to open, I get the following message:
The folder “Test” can’t be opened because you don’t have permission to see its contents.


Hope this makes some sense... Any pointers to make this work would (again) be greatly appreciated!

Take care
Posted Image
0

#3 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 04:26 PM

Hi,
actually that is quite interesting. I just tried it myself and it works just fine.
The output you get from automount actually looks pretty good.
Are you running Leopard or Snow Leopard? There was one slight glitch when using Leopard that if you by accident mount the same share manually to your desktop then access to the automount folder will fail with permission errors as far as I remember. I don't have Leopard anymore on my systems so I can't test that. In SL this glitch is gone. So if you are running Leopard make sure to unmount any shares you might have mounted. This is the only explanation I have so far.
If this is not the case what permissions does the 'Test' folder actually have?
I just checked and mine has initially
dr-xr-xr-x    2 poldi  wheel     1B  1 Mai 11:58 Test

and when the share is attached they even change to
drwx------@ 132 poldi  wheel   4,3K  2 Mai 17:59 Test

which I should be able to access in any case. But if you try to access this with any other user it will fail. That is actually the reason why my mount points are in my home folder as you have to set them up on a per user basis with these permissions. The permissions are given by autofs/system automatically and I wasn't able to control these or alter them just yet.
So hope this will help.
Regards,
Poldi
0

#4 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 04:37 PM

Actually I just found out that autofs creates the mount point if it is not there. So you can try to skip the first step in case there was something funny with the folder you created as mount point. Although I doubt that this has anything to do with it.

Poldi
0

#5 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 02 May 2010 - 05:09 PM

I'm running 10.6.3, on an iMac with only one (admin) account.

I'm trying to automount a Synology box with 5 (separate) volumes (in my case 5 disks); media1 through media5, media1 has a folder named movie.

I've tried this:

#Mount AFP shares from synology

synology:/media1/movie /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/media1/movie 0 0


and this

#Mount AFP shares from synology

synology:/Volumes/media1/movie /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/Volumes/media1/movie 0 0


With or without the folder Test created, same result, an blank alias icon that I cannot access.

Would like to try to get the permissions of Test, but would need some directions on how to do this.

Many thanks!
Posted Image
0

#6 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 05:10 PM

One more thing. While testing a bit more I got the same issue you reported. I created two different mounts in exactly the same way. One worked fine the other complaint about lacking permissions. And the symbol was the one with the folder and the stop sign. I removed the mount from fstab and ran the automount -vc again and re-added it again afterwards. The symbol looked better and the permissions where ok but still the same error message. What the heck!
I then logged off and on again and suddenly everything was peachy again. So if your permissions for the folders look like mine you might also consider rebooting or login out and in again.

Poldi
0

#7 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 05:20 PM

View Postsmoldersonline, on 02 May 2010 - 05:09 PM, said:

I'm running 10.6.3, on an iMac with only one (admin) account.

I'm trying to automount a Synology box with 5 (separate) volumes (in my case 5 disks); media1 through media5, media1 has a folder named movie.

I've tried this:

#Mount AFP shares from synology

synology:/media1/movie /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/media1/movie 0 0


and this

#Mount AFP shares from synology

synology:/Volumes/media1/movie /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/Volumes/media1/movie 0 0


With or without the folder Test created, same result, an blank alias icon that I cannot access.

Would like to try to get the permissions of Test, but would need some directions on how to do this.

Many thanks!



Ok I see.
For starters I don't know if you can access a folder in a share that way.
So for instance if media1 is your share then you should use this:
#Mount AFP shares from synology

synology:/media1 /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/media1 0 0


Try if this will work. If you want the movie folder then you have to set up the movie folder as an AFP share on your synology box.
I can't test it since I have to run now but will try later how this would behave on my system.
To get the permissions open Terminal and type
cd ~/Desktop

to navigate to your Desktop and then type
ls -l

which displays you the content of the Desktop in a list view (-l). Look for the Test folder in there and copy that line.
Regards

Poldi
0

#8 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 02 May 2010 - 05:21 PM

Must be something wrong with the permissions:

Posted Image

Will try rebooting....

Edit: rebooting or logging off will not help. Thanks for pointing me to the permissions:

dr-xr-xr-x   2 root    wheel       1 May  2 19:32 Test


Where mine reads root, I guess it should read imac27...., anyway that's the case for the rest of the files and folders, e.g.:

drwx------@ 62 imac27  staff    2108 Apr 25 18:22 Harmony 1100 icons
drwxr-xr-x@  4 imac27  staff     136 May  2 14:16 NZBs
dr-xr-xr-x   2 root    wheel       1 May  2 19:49 Test


I'm out of my depth here......
Posted Image
0

#9 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 02 May 2010 - 10:20 PM

View Postsmoldersonline, on 02 May 2010 - 05:21 PM, said:

Must be something wrong with the permissions:

Posted Image

Will try rebooting....

Edit: rebooting or logging off will not help. Thanks for pointing me to the permissions:

dr-xr-xr-x   2 root    wheel       1 May  2 19:32 Test


Where mine reads root, I guess it should read imac27...., anyway that's the case for the rest of the files and folders, e.g.:

drwx------@ 62 imac27  staff    2108 Apr 25 18:22 Harmony 1100 icons
drwxr-xr-x@  4 imac27  staff     136 May  2 14:16 NZBs
dr-xr-xr-x   2 root    wheel       1 May  2 19:49 Test


I'm out of my depth here......


Hi,
did you also try my previous comment?
Because I just tested how it would behave if you try to access YOUR_SHARE/SOME_FOLDER and this gives me exactly what you describe. I get a generic alias icon on the folder which I cannot access due to permission errors. And also if I check the permissions the folder is owned by root.
So I take a guess right now that what you have set up for your Synology box as shares is media1 through media5. That would mean you need to use
#Mount AFP shares from synology

synology:/media1 /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology/media1 0 0

and nothing else.
Try to see in your Synology admin interface what has been defined as shared folders and what the path is to those. And use exactly that as YOUR_SHARE. I am sorry that I can't be more explicit. I only know the QNAP config page and not the Synology one.
Regards,
Simon
0

#10 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 03 May 2010 - 06:53 AM

I'm getting close to giving up on this and no doubt you must have better things to do. At any rate thank you very much for helping me!

Synology uses the term "Shared Folder". With those mounted, I get the following path for the folder movie: /Volumes/media1/movie. I have tried your above suggestion and also some variations (e.g. with /Volumes). No luck, I get the blank (root) icon, whatever I try. Logging off and rebooting does not help.

Posted Image

Maybe this is just not for me......

Take care!



EDIT: Whoot, I got it to work with cifs in stead of afp. :lol: @Poldi: did you try this with afp?

EDIT2: And now also with afp! fstab reads as follows:

synology:/media1 /Users/imac27/Desktop/Test url automounted,url==afp://admin:********@synology._afpovertcp._tcp.local/media1 0 0


Again, thanks a lot!!
Posted Image
0

#11 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 03 May 2010 - 05:23 PM

Wow man, great! Good thing you got it working now because I was running out of options. Don't know why the synology._afpovertcp._tcp.local makes all the difference but on a second thought that is the server url you get displayed when you select the share mounted on the desktop and hit COMMAND+I. Good thinking, actually!
That is your router who doesn't like the server name. We should have tried using either the IP address or synology.local which should probably work as well.
But then again, nevermind.
Have some Stroopwafels on me or even better send me some ;)
Cheers,
Poldi
0

#12 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 03 May 2010 - 07:43 PM

This is probably very obvious, but just in case....

I wasn't really looking forward to re-scrape my library and to (again) add all my custom artwork. The trick for me is to mount the shares to /Volumes/YOUR_SHARE, in my case:

synology:/media1 /Volumes/media1 url automounted,url==afp://admin:********@synology._afpovertcp._tcp.local/media1 0 0

With this, Plex runs like normal (and so do other applications, e.g. SABnzbd). In Finder's sidebar, I have a shortcut (under Places) to Volumes, so I can reach the shares without touching (mounting) the NAS (under Shared). In case I still mount the NAS' shares, I have two identical shortcuts in /Volumes, media1 and media 1-1, that's no problem.

This option is especially helpfull for my Plex dedicated (no keyboard) Mac mini. Right now, I'm working with a script, but no need for that anymore (after some more testing) :).

Thanks and take good care!

Dirk
Posted Image
0

#13 User is offline   vicariousMe 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 356
  • Joined: 28-August 09
  • Gender:Not Telling

Posted 04 May 2010 - 06:15 AM

View Postsmoldersonline, on 03 May 2010 - 07:43 PM, said:

This is probably very obvious, but just in case....


Thanks Poldi for the original post and Dirk for the idea to mount in /Volumes -- I'm in awe at how well this is working.

Vicarious
Plexflix: Add videos from your Netflix Queue and from Hulu directly to your TV Show or Movies folders in Plex.
Preen: Skin manager for Plex 0.9.
StreamWeaver for Netflix Movies: Add Netflix's top-rated movies to Plex.

Netflix Problems in Plex?
0

#14 User is offline   Jez 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 14-September 09

Posted 12 June 2010 - 11:37 PM

Hi there,

First of all, many thanks for all the hints and tips so far! I was previously using a login item to mount my nas via AFP but I kept running into intermittent issues where I'd end up with multiple versions of the same mount (e.g. original mount was Media and I ended up with Media-1 as well).

I've set up the autofs for the AFP mount to /Volumes/Media and it works perfectly, except for one thing.....how can I get the mount to display in the finder? I'm using the same mount to access my iTunes library but I can't point iTunes to that directory as it's not showing up in the Finder! Going in via the command line is fine - I can see the mounted directory and the files inside it.

Any clues gratefully received!

Jez
0

#15 User is offline   smoldersonline 

  • Dedicated Member
  • PipPipPip
  • Group: Members
  • Posts: 245
  • Joined: 30-August 08
  • Gender:Male
  • Location:The Netherlands

Posted 13 June 2010 - 06:31 AM

@Jez: Maybe you could try adding the Volumes folder to Finder's sidebar. By default, the Volumes folder is hidden, so first you should make it visible. I use the Secrets PrefPane to do this. Then, just drag it to Finder's sidebar (under Places). When you hide the hidden files (back to default), the Volumes folder will stay in the sidebar.

Hope this makes sense and helps.
Posted Image
1

#16 User is offline   Jez 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 14-September 09

Posted 14 June 2010 - 01:29 PM

View Postsmoldersonline, on 13 June 2010 - 06:31 AM, said:

@Jez: Maybe you could try adding the Volumes folder to Finder's sidebar. By default, the Volumes folder is hidden, so first you should make it visible. I use the Secrets PrefPane to do this. Then, just drag it to Finder's sidebar (under Places). When you hide the hidden files (back to default), the Volumes folder will stay in the sidebar.

Hope this makes sense and helps.


That makes perfect sense, thank you! I managed to get round it by navigating to the folder directly from the Finder menu then I could use Recent Folders in iTunes and it all seems to be working perfectlt.

I'll definitely donwload that PrefPane though as it will certainly make life easier....

Jez
0

#17 User is offline   chriszammett 

  • Member
  • PipPip
  • Group: Members
  • Posts: 85
  • Joined: 15-January 09
  • Gender:Male
  • Location:Oxfordshire, UK

Posted 24 June 2010 - 03:30 PM

I am going to have a setup whereby I have one G5 with all my media on it and two other computers sharing the files (a mac mini and a hackintoshed dell). Do I do this work on the computers that are receiving the shared files, or the 'sharer' (g5)

thanks
chris
0

#18 User is offline   koppenhoefer 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 07-July 10

Posted 07 July 2010 - 03:13 PM

Nice article,.. now added to my list of oh-no-help-me!-RESOURCES for afp :-)

Do you know how I might decrease the automount TIMEOUT value for when the mount is failing (ie. due to a firewall between the afp client and server)?
If I set up my afp server to NOT ALLOW afp from a particular client, but I ssh into that client.. provoking the automount attempt at login... I have to wait 120seconds (arggh!) before I'm finally allowed it. Can I set that value somehow?

I thought I'd find something in /Library/Preferences/com.apple.AppleFileServer.plist
or else in DirectoryUtility
but no joy.

Any ideas?

/shawn
0

#19 User is offline   steven77 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 18-July 10

Posted 18 July 2010 - 06:55 PM

Hi Poldi,

Thank you very much for this great article. Everything works perfect except one constellation - maybe you know why:

When I relocate my home folder to a home folder on the automounted smb share, the automount won't work (and therefore, no home folder is available. Error message: Source behind alias is not available).

No clue what is the problem behind that, because the script should work independent from a user.

Have found the following in an apple whitepaper but not sure if it applies to the situation (http://images.apple....docs/Autofs.pdf):

"A common way to set up user network home directories is to create automounts in Mac OS X Server (as shown in “Server Admin”). Since autofs does not mount AFP or SMB shares using Kerberos or individual user credentials, the automounted home shares are unmounted by Login Window and remounted using the user’s credentials from the Login Window. This allows the shares to be mounted with the correct credentials and permissions.
If a user logs in to Mac OS X via SSH and not via the console, Login Window is not available to unmount the automounted home directory and remount it as the user. If the user’s home directory is on AFP, the user can run the mnthome command to unmount the automount and remount it using the user’s Kerberos credentials."

OS 10.6.4
Synology DS-110j

Thx in advance for any help!

Cheers
Stephan
0

#20 User is offline   Poldi 

  • Member
  • PipPip
  • Group: Members
  • Posts: 34
  • Joined: 29-August 09
  • Gender:Male
  • Location:Germany

Posted 19 July 2010 - 06:11 PM

View Poststeven77, on 18 July 2010 - 06:55 PM, said:

Hi Poldi,

Thank you very much for this great article. Everything works perfect except one constellation - maybe you know why:

When I relocate my home folder to a home folder on the automounted smb share, the automount won't work (and therefore, no home folder is available. Error message: Source behind alias is not available).

No clue what is the problem behind that, because the script should work independent from a user.

Have found the following in an apple whitepaper but not sure if it applies to the situation (http://images.apple....docs/Autofs.pdf):

"A common way to set up user network home directories is to create automounts in Mac OS X Server (as shown in “Server Admin”). Since autofs does not mount AFP or SMB shares using Kerberos or individual user credentials, the automounted home shares are unmounted by Login Window and remounted using the user’s credentials from the Login Window. This allows the shares to be mounted with the correct credentials and permissions.
If a user logs in to Mac OS X via SSH and not via the console, Login Window is not available to unmount the automounted home directory and remount it as the user. If the user’s home directory is on AFP, the user can run the mnthome command to unmount the automount and remount it using the user’s Kerberos credentials."

OS 10.6.4
Synology DS-110j

Thx in advance for any help!

Cheers
Stephan


Hi,
actually I don't know if my solution can be used for that. You are a bit on your own there as I have never tried that, however I could imagine that such a feature is used quite often in combination with MaC OS X server.
You might want to start with rajeev's guide Part 1. This auto_home thingy is exactly what you want. The example is for nfs which you could set up on your Synology NAS as well. Otherwise you need to find out how to configure a SMB share in /etc/auto_home.
Regards

Poldi
0

Share this topic:


  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

3 User(s) are reading this topic
0 members, 3 guests, 0 anonymous users