mount_afp on system bootup (not login)?

Discussion in 'Mac Basics and Help' started by weboweb, Mar 27, 2009.

  1. weboweb macrumors newbie

    Joined:
    Mar 27, 2009
    #1
    Hi folks,

    I need to mount an AppleShare volume on system boot up (i.e. before anyone logs in). This is in fact on a headless server which I am setting up through bash.

    Where can I stick my

    "mount_afp afp://user:pass@theserver/ /Volumes/shareddisk"

    command to run it on bootup? I had a look into fstab but am not sure if I'm on the right track. Any help would be greatly appreciated.
     
  2. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #2
    Cron. Run crontab -e then press i and create a new line with

    @reboot mount_afp afp://user:pass@theserver/ /Volumes/shareddisk

    When you're done, press escape, then type :wq and hit return.

    Oh, sorry. I missed the bit about startup. I believe cron should still work if you specify a different user, maybe root.
     
  3. weboweb thread starter macrumors newbie

    Joined:
    Mar 27, 2009
  4. weboweb thread starter macrumors newbie

    Joined:
    Mar 27, 2009
    #4
    Hmm... now I'm tearing my hair out.

    I understand I need my mount_afp commands in /etc/rc.local, but I am having some problems. If I have the following commands in rc.local, the device mounts okay, but it's mounted as root so my other software can't access it:
    Code:
    #  /etc/rc.local
    
    mkdir /Volumes/my_mount_point
    mount_afp afp://user:pass@192.168.0.2/folder /Volumes/my_mount_point
    So I tried to run the commands by sudoing to the user I needed it to be mounted under, like this:

    Code:
    #  /etc/rc.local
    
    sudo -u sysadmin mkdir /Volumes/my_mount_point
    sudo -u sysadmin mount_afp afp://user:pass@192.168.0.2/folder /Volumes/my_mount_point
    But the mount_afp command would fail, with the following error (from /var/log/system.log):


    Code:
    # /var/log/system.log
    
    myhostname sudo[141]:	root : TTY=unknown ; PWD=/ ; USER=sysadmin ; COMMAND=/sbin/mount_afp afp://user:pass@192.168.0.2/directory /Volumes/my_mount_point
    
    com.apple.SystemStarter[51]: mount_afp: [b]AFPMountURL returned error -1069 errno is -1069[/b]
    error 1069 apparently occurs when the device to be mounted cannot be found, but it's definitely there, and if I run the mount_afp command when logged in as sysadmin, it works.

    Does anyone have any ideas? Can I just mount it as root and then chown to sysadmin? I tried adding chown sysadmin -R /Volumes/my_mount_point to the first script, but it failed.

    I am running out of ideas given my limited experience with unix, and apple's extensions to it. Any help, even a poke in the right direction, would be much appreciated.
     
  5. peter.mcmahan macrumors newbie

    Joined:
    May 21, 2009
    #5
    I was getting that same error trying to use mount_afp in single-user mode. It turns out I simply didn't have network access (I don't know if that applies to you).

    In any case, I found the following directions for manually enabling network access in single-user mode at
    http://www.macos.utah.edu/documentation/system_deployment/radmind/faqs/single_user_mode.html


    Code:
    % fsck -fy (or skip it at your own peril)
    % mount -uw /
    % launchctl load /System/Library/LaunchDaemons/com.apple.kextd.plist
    % launchctl load /System/Library/LaunchDaemons/com.apple.notifyd.plist
    % launchctl load /System/Library/LaunchDaemons/com.apple.configd.plist
    % launchctl load /System/Library/LaunchDaemon/com.apple.DirectoryServices.plist 
    Along with these notes:

    it all worked for me, and I was able to successfully mount a network AFP share! Thought It would be useful on this thread.
     

Share This Page