mount_afp on system bootup (not login)?

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

  1. weboweb macrumors newbie

    Mar 27, 2009
    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


    Jul 26, 2004
    Montreal, QC
    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

    Mar 27, 2009
  4. weboweb thread starter macrumors newbie

    Mar 27, 2009
    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:
    #  /etc/rc.local
    mkdir /Volumes/my_mount_point
    mount_afp afp://user:pass@ /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:

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

    # /var/log/system.log
    myhostname sudo[141]:	root : TTY=unknown ; PWD=/ ; USER=sysadmin ; COMMAND=/sbin/mount_afp afp://user:pass@ /Volumes/my_mount_point[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

    May 21, 2009
    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

    % fsck -fy (or skip it at your own peril)
    % mount -uw /
    % launchctl load /System/Library/LaunchDaemons/
    % launchctl load /System/Library/LaunchDaemons/
    % launchctl load /System/Library/LaunchDaemons/
    % launchctl load /System/Library/LaunchDaemon/ 
    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