Mount AFP Share

From Center for Cognitive Neuroscience
Jump to navigation Jump to search

Using the GUI

This is done in X simple steps:

  • In Finder, either use the hot key CMD+K or in the Menu Bar Go => Connect To Server
  • In the resulting window's Server Address field enter the IP Address or Domain Name of the computer you want to connect to preceded by afp://. For this example, we'll use the miles server.
afp://fmri00-miles.hosted.ats.ucla.edu
  • Then click the Connect button located in the bottom right of the window.
  • You will be presented with Login Screen. Enter your miles username and password into the field and select "Save to Keychain" if you'd like the computer to remember this information.
  • Finally, after completing the login you are presented with available Share Points. This list most likely includes your home directory and in the case of Miles, Songbook1 and Songbook2.

You can now access this data through Finder just like a local drive or by browsing to /Volumes/<sharename> where sharename is the name of the drive you mounted.

Using the Command Line

To mount the disk (say if it's a firewire on a remote host that is connected, but not mounted), do the following:

  • ssh into the remote host
  • execute the following command
$ diskutil mountDisk /dev/disk2

Note that "disk2" may change. If your not sure what the disk# is, the following command will find out for you (again, for a firewire disk):

$ system_profiler SPFireWireDataType | grep "BSD Name: disk.$"

After the disk is mounted on the remote machine, you can mount it locally via the command line like so:

  • Create a mount point. The most common is /Volumes/someDirName, though it can be anywhere (such as /Users/you/myMountPoint
$ mkdir /Volumes/MyShare
  • Mount the drive onto MyShare (or whichever directory you wish) where ShareName is the name of the share you wish to mount.
$ mount_afp -i afp://192.168.1.25/ShareName /Volumes/MyShare

To then unmount (disconnect) the afp share, do the following

$ umount /Volumes/MyShare

And if you wish to "clean up", delete the now empty directory:

$ rmdir /Volumes/MyShare

One Step Mounting

The following will mount your share in a single step:

$ mkdir /Volumes/MyShare; mount_afp afp://username:password@192.168.1.25/ShareName /Volumes/MyShare

The following will unmount your share and remove the mount directory

$ umount /Volumes/MyShare; rmdir /Volumes/MyShare

By using the above commands in a script and integrating with a backup method of choice (like rsync or tar), you could easily do one step backups of important data. Even more indicative of ninja like kung-fu skills, that script could then be added to a cron job make the process completely automatic and hands free.