2

When I use the command line rather than the finder to mount a network volume, and I want the mount point to be in /Volumes, do I need to create the mount point myself first? If so, how should I do that so i still can unmount from the UI without problems? The finder seems to ignore the actual share, so the mount point it creates is /Volumes/HOST._afpovertcp._tcp.local without a reference to the share.

4
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Sep 14 at 7:15
  • Can I use the command line to mount an afp network share so the result is exactly the same as if I used the Finder to mount this share? The problem I see is that the mount point created by the finder can differ, they seem to be /Volumes/HOST._afpovertcp._tcp.local for the first share of a network volume, but subsequent shares are mounted on /Volumes/SHARE Commented Sep 14 at 7:50
  • open afp://user@HOST/SHARE is almost identical to the Finder behaviour, with the exception that it will prompt me for the password, while to Finder allows that to be permanently remembered Commented Sep 14 at 8:59
  • if I use the exact url the finder uses, open afp://HOSTNAME._afpovertcp._tcp.local/SHARE causes the dialog box in the Finder to be prefilled with the cached password, but a click is still needed :-( Commented Sep 14 at 9:13

3 Answers 3

2

To replicate what happens when you mount a network share in the Finder, use a command of this form:

osascript -e ‘mount volume "afp://user:password@HOST/SHARE”’

To mount an SMB share, replace “afp” with “smb”. The user name and password can be omitted if the command is executed in a local shell on the file-sharing client, the credentials are stored in the Keychain, and the Keychain is unlocked.

1
  • Thank you. This command can indeed be used to mount a network share with no prompt, i.e. using cached credentials, provided you use the exact same url as the finder, so in my case afp://HOST._afpovertcp._tcp.local/SHARE. Commented Sep 15 at 7:33
2

You can use the mount command to mount a network volume to any existing directory (or in other words: yes, you need to create it first before mounting). It has been a while since I used AFP, but

sudo mkdir -p /Volumes/afpshare
sudo mount "afp://user:password@HOST/SHARE" /Volumes/afpshare

should work.

Any mounted volume shows up in Finder and can be ejected from there.

-1

This should work

sudo mkdir -p /Volumes/mount_point # only need to do this once
sudo /sbin/mount_afp 'afp://user:passwd@host/share' /Volumes/mount_point
New contributor
user1296623 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 8 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .