Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

weboweb

macrumors newbie
Original poster
Mar 27, 2009
3
0
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.
 
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.
 
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.
 
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:

1. There no longer is /etc/rc. launchd is here to stay. Learn it, and maybe learn to love it.
2. Even though the Program path in the launchd plist for kextd is still /usr/libexec/kextd, it won't work if you just run it at the command line. You must start it via launchctl.
3. We have the addition of notifyd in the steps compared with 10.4. Without it, configd won't load.
4. lookupd is no more. All hail /usr/sbin/DirectoryService.
5. You can write the commands for launchctl into a file and then pipe it into launchctl as stdin. That sure saves a lot of typing!

it all worked for me, and I was able to successfully mount a network AFP share! Thought It would be useful on this thread.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.