Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

Howto automount AFP/SMB shares using autofs

124

Comments

  • ManMan Members Posts: 246 ✭✭
    edited August 2011
    .
  • NIK640NIK640 Members Posts: 1
    Raka74 wrote:

    Hi there,

    Thanks for that, it looks like this works for me, after I installed Lion on my mini automount afp did not work anymore , so I enabled NFS on my Synology and mounted it under /Users/../Media


    I still can't get this to work with my Synology, entered everything as you guys said but when I click verify it tries to connect then gives me the message "The NFS Server Did Not Respond"

    I'm running a new i5 Mac Mini that I'm using solely as a HTPC and Synology DS1511 connected via ethernet.

    Thanks for any help
  • boots2xboots2x IP Challenged Ninja Members, Plex Pass, Plex Ninja Posts: 1,184 Plex Ninja
    Soli wrote:

    Still broken in 10.7.1. It´s sad how Apple is turning our computers into large iPads...
    Anyways, it seems like it won´t be fixed anytime soon, so I guess I´m off to try NFS mounts.


    Boots: I am under the impression that both AFP and SMB/CIFS are broken.

    WhoCares from over at ReadyNAS forums told me that CIFS should work - but I confess I haven't yet tried! AFP is certainly not working for me. When I get time to try this out again, I'll report back.

    James

    These resources are your friends! The Plex Help Center | The Plex Forums | Forum Search is DEFINITELY your friend!

    Check the Plex Media Preparation Guide! | Learn how to collect Log filesGet MediaInfo to analyse video files

    Plex Media Server: Mac OS X and ReadyNAS Pro 6 | Plex Clients: Mac Mini 2010 2.66Ghz, 2Gb RAM, AppleTV Gen 2, iPhone 3GS | LG 56" DLP-TV | Sherwood AV Amp | Storage: ReadyNAS Pro 6 with 6 x 2Gb Hitachi HDD for 8Tb storage | Network: Cat 6 cabled, 1000BaseT

  • lazantlazant Members, Plex Pass Posts: 25 Plex Pass
    Just upgraded to Lion and can confirm that this method is broken... oh well.
  • ManMan Members Posts: 246 ✭✭
    It should be easy enough to fix. The problem is with access rights. Lion mounts the auto shares with only root access. You could enable root user, and login as root... so it is a workaround. I even tried to edit the groups file to give root access to my user. Apparently this normally works in unix type OSe, but of course it didn´t work in Lion....
  • bitmeizerbitmeizer Members, Plex Pass Posts: 1 Plex Pass
    edited September 2011
    After banging my head around all day, I've managed to come up with a solution in Lion that seems to work. Basically, skip 'fstabs' and go directly to adding mount details into '/etc/auto_master'. Here's what I did:

    1. Add a new map to '/etc/auto_main'. In my case, I decided to create a directory in the root called '/Shares', which makes it global, visible to Finder, and will let me have the same path if I ever move Plex to another machine. For whatever reason, putting it into '/Volumes' didn't work. Couldn't figure out why.

    sudo vi /etc/auto_master
    


    Use your favourite editor in place of 'vi'. Add the following line to the end of the file:

    /Shares auto_cinema
    


    Then, add a new file called '/etc/auto_cinema', with the details of your shared mounts. In my case, they are AFP via an Airport Extreme and Time Capsule.

    sudo vi /etc/auto_cinema
    


    Then the file itself:

    Movies -fstype=afp afp://user:pass@MyAirPortExtreme.local/Share/Movies
    TV -fstype=afp afp://user:pass@MyTimeCapsule.local/Share/TV
    


    You can map the folder name to something different to actual folder on the shared path, but it may get confusing in Finder, since it will 'rename' the folder in the display to whatever it is actually called in the shared folder.

    Then, just reboot or get 'automount' to restart. Eg:

    sudo automount -vc
    


    Tada! (Fingers crossed...)

    Anyway, hope this helps someone else... Good luck!

    David
  • ManMan Members Posts: 246 ✭✭
    David, if you read a little closer, then you will see that both automounting methods did not work.
    I´m happy it seems to work for you, but will it work after a couple of reboots?
    The same has happened to me too, for both mounting methods. Suddenly it just works, and one time even survived multiple boots. And then when I was going to write on this very forum that I found the solution, it then died on me ;)
    Anyways..I´ll try it once more just for the sake of it..
  • MackoryMackory Members Posts: 1
    After I read the article and following step by step, I found the volume(folder) i was trying to connect is missing! (Not on the desktop and destination folder)

    But I can see in Finder, and the connection by afp also works fine. Just the icon which were supposed to be on the desktop is gone.

    What happened? Is it because I delete the destination route in my OS? And I just put the etc/fstab back to blank, but it doesn't help.

    Thanks for your help!
  • CapybaraCapybara Members Posts: 88 ✭✭
    I've been having the same problems with my drobo shares. Sometimes it works fine. Now I'm getting this:
    lsof: WARNING: can't stat() autofs file system /Users/user/Shares/prop
          Output information may be incomplete.
          assuming "dev=2c000006" from mount table
    lsof: WARNING: can't stat() smbfs file system /Users/user/Shares/prop
          Output information may be incomplete.
          assuming "dev=2e000076" from mount table
    

    when I run lsof, for only one of the shares

    I'm on Lion 10.7.1
    my shares are on a Drobo FS (both cifs and afp shares)
    all my maps are in /etc/fstab ,not the /etc/auto_smb auto_afp way
  • ManMan Members Posts: 246 ✭✭
    edited October 2011
    still f***** u* in 10.7.2

    edit:
    Seems I got this working.. :D
    Ill test it a day or two just to see if it really does work.
    The workaround is so simple..it will blow your mind..
  • CapybaraCapybara Members Posts: 88 ✭✭
    has anyone tried the
    vifs
    
    command? I had been editing /etc/fstab with vim, but according to the man page for vifs, you should never edit fstab with anything other than this tool.
    NAME
    vifs -- safely edit fstab

    SYNOPSIS
    vifs

    DESCRIPTION
    The vifs utility simply locks the fstab file before invoking an editor on it. This is
    important to facilitate the modification of fstab by automated tools and system manage-
    ment software.

    Always use vifs to edit fstab, instead of invoking an editor directly.

    I just backed up my original file and created a new one with this utility. Everything looks ok so far, but I won't know for sure until I've restarted a few times and my shares are mounting correctly.
  • MatthewTavaresMatthewTavares Members, Plex Pass Posts: 23 Plex Pass
    edited October 2011
    I have gotten mine auto mounting again with this method

    Open the Terminal.app and sudo to root.

    sudo su –

    enter your root password when requested

    Next you need to create a file to manage all of your SMB mounts.

    nano /etc/auto_smb

    Add the single line below to the newly created /etc/auto_smb file.

    /Volumes/AAA -fstype=smbfs ://BBB:CCC@D.D.D.D/EEE
    Where
    AAA = The name you want it to mount under
    BBB = Your username on the computer you want to mount a share from
    CCC = Your Password for your username
    D.D.D.D = The IP address of the computer you want to mount a share from
    EEE the Share name that you are mounting
    Mine for example looks like this
    /Volumes/Data -fstype=smbfs ://Matt:myfakepassword@192.168.1.99/Data

    After saving the file with ctrl x and then y be sure to make it read only by root.

    chmod 600 /etc/auto_smb

    Now we need to tell Autofs to load our SMB sharepoints. Edit the file /etc/auto_master

    nano /etc/auto_master

    and add the following line to the bottom of the file.

    /- auto_smb

    Finally, we need to mount our shares. This can be done by rebooting or running the following command or rebooting.

    automount -vc

    I have had it running for about 2 weeks now and it has been working just as the old fstab method did. It seems to be mounting it as a normal user so plex has no problems seeing it. Hopefully this will be the case for everyone.

    full credit goes to This guy as that is where I found this method

    For reference, my setup is as follows
    Client
    2010 Mac Mini Base Model with 8GB ram.
    Mac OSX Lion 10.7.2 (Upgrade install from snow leapord)
    Plex 0.9.3.4
    in network settings on my mac I am "Using DHCP with manual address" (static ip)
    Gigabit ethernet with wifi disabled

    Server
    Windows 7 Professional SP1 with a static ip
  • ManMan Members Posts: 246 ✭✭
    Must have been fixed in 10.7.2. It is still not working properly with fstab, and I do prefer FStab since it is stativ and not dynamically mounted as with the auto_afp or auto_smb method. I did find a solution with fstab, so it is working properly for me.
  • MatthewTavaresMatthewTavares Members, Plex Pass Posts: 23 Plex Pass
    Soli wrote:

    Must have been fixed in 10.7.2. It is still not working properly with fstab, and I do prefer FStab since it is stativ and not dynamically mounted as with the auto_afp or auto_smb method. I did find a solution with fstab, so it is working properly for me.


    What is the difference?
  • ManMan Members Posts: 246 ✭✭
    I´m no expert so this will be in layman´s terms:
    Static is always a part of the filesystem.
    Dynamic will be mounted as needed.

    If I have my itunes songs in a dynamic share and I press play, iTunes might stop and display a "!" beside the song. The following songs will play fine if I push play again. If the server that hosts the share is down, then also dynamic shares will after a while stop retrying. If i run a backup to a dynamic share then the backup program might complain that the path is not found. Your experience might vary, though.

    with a static share, I could turn off the server hosting the share for 1 month and then turn it on again, and it would still work.
  • probusprobus Members Posts: 2
    Soli wrote:

    Must have been fixed in 10.7.2. It is still not working properly with fstab, and I do prefer FStab since it is stativ and not dynamically mounted as with the auto_afp or auto_smb method. I did find a solution with fstab, so it is working properly for me.


    Why don't you share your solution for fstab? Auto_smb is not working for me because of problems with permissions.
  • ManMan Members Posts: 246 ✭✭
    edited October 2011
    Oh, Im sorry. I thought I already did, but I see now that I forgot.



    Here it is:
    Do your usual thing in fstab.
    Start Applescript editor.
    write this
    do shell script "diskutil unmount shares/share2;diskutil unmount /shares/share1;automount -vc > /dev/null 2>&1 &" user name "your_user_name" password "your_password" with administrator privileges

    Example: If I have defined 3 shares in fstab in Volumes/Film , Volumes/Music , Volumes/Other, it would be like this :

    do shell script "diskutil unmount Volumes/Film;diskutil unmount Volumes/Music;diskutil unmount Volumes/Other;automount -vc > /dev/null 2>&1 &" user name "your_user_name" password "your_password" with administrator privileges

    Save the script as an application, and drag it to login items. Haven´t failed me a single time. I have tried numerous times without the script and I run into the dreaded permissions bug each time.


    I haven´t found out if you could put the script in some other places so that OSX would execute it before login. Basically you would want to run the script after OSX has executed fstab. I did try to put it in RC.local but that did not work out. maybe /maybe not as a launchdaemon. I use autologin so I´ll let someone else figure it out :)
    I suspect this will work with the auto_afp and auto_smb method too.


    It is possible to make the script execute as a launchd useragent, but that one executes after login too. Even though, tt will be a little more elegant as you wont see the applescript popping up on the dock at login. (Dont worry, it closes automatically) I just did not bother more with it after I found a working solution.
  • probusprobus Members Posts: 2
    Soli wrote:

    Oh, Im sorry. I thought I already did, but I see now that I forgot.


    Thanks. I can confirm this works for auto_afp as well. I was thinking about doing something similar with launchd (since auto_afp needs unmounting as well) but now I don't have to, which is great because every little thing seems to take hours to do because of some bugs or whatever..

    Unfortunately one still can't control the permissions as this will mount with permissions only for the user logging in. This won't work if you have multiple users that need access to the share. We like to keep all users logged in all the time since switching users is so much more convenient than loggin in/out every time. I originally wanted to mount the shares before logins for this reason.

    Turns out that's not possible, but now I at least have a workaround. I mount the same share to multiple different folders using automount (/Volumes/Share_user1, /Volumes/Share_user2 …) and then use the applescript to change the permissions for one of those mounts during each user's login. In case someone else is struggling with this, here's how it's done:

    For example if you have one share and two users, put the lines in auto_afp:
    /Volumes/Share_user1 -fstype=afp afp://user:password@server/Share
    /Volumes/Share_user2 -fstype=afp afp://user:password@server/Share

    For user1, put this applescript to the login items (Soli's method):
    do shell script "diskutil unmount Volumes/Share_user1;automount -vc > /dev/null 2>&1 &" user name "your_user_name" password "your_password" with administrator privileges

    and for user2:
    do shell script "diskutil unmount Volumes/Share_user2;automount -vc > /dev/null 2>&1 &" user name "your_user_name" password "your_password" with administrator privileges

    This will create two mountpoints for the same share with each user having access to one but not the other. Both can be logged in at the same time and have access to the same network share. It should work using stab too, but I use auto_afp. Of course it gets a bit complicated when the amount of users or network shares grows, but the at least it seems to work.
  • anasazianasazi Members, Plex Pass Posts: 94 Plex Pass
    Is there someone who has managed the get this working without any problems?
    I have used the solution in the first post and it was woking for some days but then all of sudden it stopped working.
    I have now tried many different ways to get my shares mounted but no one is working...

    Tips anyone?
  • ManMan Members Posts: 246 ✭✭
    Why don´t you read the 2 last posts.. :rolleyes:
Sign In or Register to comment.