Automounting Network Drives (Mac)

I wish I could use my cluster's enormous space locally! --Nima (and also, possibly you)

Data data everywhere, but not on this machine

When you work with genomic data, you tend to fill up hard drives very quickly. In the lab we have several network data stores, including a half dozen network attached storages (NASs; known at the vaults) and large volume on our building cluster, diller. Command line tools like ssh and scp work well to access and transfer this data, but what do you do if you want to browse it on your desktop machine through, say, Mac OSX's finder? Luckily, a filesystem client called sshfs will allow you to do this with data on any machine with ssh access.


Installing OSX fuse and sshfs

But first, homebrew
I'm going to assume that you know what homebrew is and that you have it installed. In a nutshell, homebrew allows you get easily get new software from the command line. If you don't have it installed, you can get it with just ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)". Check out their website!

Next, FUSE
Fuse is essentially the backend that makes filesystem ownership by a user possible. sshfs needs it, so go ahead and download and install it from here.

Now sshfs
OK, assuming thats done, now all you have to do is brew install sshfs. This will put the sshfs command on your machine. Easy.


Connecting to your data

Now, to mount (diller's) data to your local machine. I'm going to mount my home directory on the diller cluster to a folder called SVM on my Mac Desktop. The examples below will be for my needs, but you can replace the sshfs arguments with whatever you'd like.

  1. Create a directory on your local machine to house remote data: mkdir ~/Desktop/SVM

  2. Now tell sshfs to mount your home directory to this new folder: sshfs carioc@diller:/home/carioc ~/Desktop/SVM -ovolname=SVM

    • Note the similarity of the first argument to ssh. Its essentially username @ machine : remote-folder.
      • I have an ssh alias for the diller cluster so I don't have to type an IP address each time.
      • I also use ssh-key login so I don't have to type my password. This is highly recommended
      • Or you can use my tool to do both these things for you (Witte Lab only at the moment, sorry)!
    • The second argument is where you want to mount the remote data locally, similar to scp
    • Finally, the third argument -ovolname just specifies how you want to name the folder. Yeah, I know, it should just use the name that you gave it when you made the folder.

  3. To disconnect, all you do is navigate to the directory containing your mounted folder and type unmount folder-name: cd ~/Desktop; umount SVM.


Doing this automatically at startup (optional)

Super... Now to do this automatically when you turn on your machine. If you google this, you'll see a million different difficult ways of doing this using automator/rc scripts. Forget all that. Just do these 3 easy steps:

  1. Open the folder containing your mounted remote files.
  2. Open System Preferences → Users & Groups → your username → Login Items. (Unlock)
  3. Drag your mounted folder into this list.

The mount should automatically happen the next time you restart your machine.