Clusters and Supercomputers in Your Finder? Meet MacFUSE.
I don't know about you, but I often have to go through rings to retrieve output data from calculations run on clusters or supercomputers, in order to analyze it on my Mac. Most of these systems are well protected, with access only via SSH. That means either trusty command-line tools like scp, or an SFTP client like Fugu. But neither of these offer the same ease of use or integration with the system as Finder. Get ready for a big change.
Unless you were in a cave for most of last week, you will probably have seen discussion of a new piece of software called MacFUSE from Amit Singh at Google. If you are like me, you probably didn't fully grasp the implications of the announcement, and moved on. Lucky for me — and now you — I was encouraged to take a closer look by a colleague (thanks Olivier!) and now realize that MacFUSE is very exciting software for Mac Researchers.
In case you are thinking the name 'Amit Singh' rings a bell, he is also author of the recently-released tome — that's a big book for those of you that flunked English — 'Mac OS X Internals: A Systems Approach'. If you ever get a chance to look through the book, do, because Amit really knows his stuff. And that's good news for us, because it means MacFUSE will no doubt evolve into a pretty useful tool.
Actually, it's already pretty useful, and here's why: MacFUSE is software that can make things that aren't filesystems — in the traditional sense — look like filesystems to your operating system. If you watch Amit's demonstration of MacFUSE, he shows how even Spotlight searches and RSS feeds can be turned into filesystems, and browsed in the Finder. These novel applications are cool, but more useful to scientists is that MacFUSE already includes support for sshfs, which is a file system based on SSH.
To try this out myself, I downloaded and installed the MacFUSE package, and then tried mounting files from a cluster that was only accessible via SSH, using this command:
/usr/local/bin/sshfs user_name@cluster.address.com:/remote/home/dir ~/Volumes/mount_dir \ -oping_diskarb,volname=Volume_Name
To try this yourself, simply enter appropriate values for each italicized string. Note that you will first need to make a directory where the filesystem will get mounted. I decided not to do it in the /Volumes directory, because I didn't want to mess with the system, so I created a Volumes directory in my home directory instead, and then a subdirectory for the cluster I was mounting. The volume name can be anything you like; it is used to represent the filesystem in the Finder.
After issuing this command, you should see the remote server files appear as a volume in the Finder. You can browse the volume as if it an afp or smb volume, dragging files to and from directories, and so forth. Of course, you can also cd to ~/Volumes/mount_dir from the command line, and do your thing there without logging in to the remote machine.
To unmount the sshfs volume, you can try using the Finder, but there has been some talk that this doesn't always work. If it doesn't work for you, drop to the command line, and unmount manually:
umount ~/Volumes/mount_dir
This is all pretty cool, but I wanted to take one more step: I wanted my sshfs filesystem to mount when I logged in. For this I used launchd, which can execute arbitrary commands on login. I created a script in ~/bin/mount_clusters containing the command above, and then used Lingon to generate the following launchd file, which I located in the file ~/Library/LaunchAgents/Mount Clusters.plist:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>Mount Clusters</string> <key>ProgramArguments</key> <array> <string>/Users/user_name/bin/mount_clusters</string> </array> <key>RunAtLoad</key> <true/> <key>ServiceDescription</key> <string>Mounts SSH file systems at login</string> </dict> </plist>
With this in place, the clusters appear in Finder whenever I login to my Mac.



Comments
Whoa
This is *very* cool. Like you, I brushed past Amit's announcement without a second thought. Two points I've discovered:
/usr/local/bin needs to be added to $PATH if it isn't there already
sshfs doesn't handle switching networks gracefully like AFP, so make sure to unmount everything first.
Pretty neat!
Thank you guys for pointing this one out. I also overlooked the anoucement when I read it somewhere on the web. I always thought that it should be a filesystem solution for ssh remote files. Now finally I found it!
I really like this site. The people in this community have pretty good ideas and information of how to make scientific research easier on Macs :-)
Juan
a bit confused
Was I supposed to install the sshfs package as well as the MacFuse?
I am getting an sshfs.app directory (I understand what that is) - but do I need to access the actual shell command as .../sshfs.app/Contents/MacOS/sshfs ?
If so, I cannot get it to take my username@machine:/home_directory, it keeps coming up with the dialog.
Any ideas here?
Thanks in advance...feeling somewhat stupid here...
Lou
try /usr/local/bin/sshfs
Did you try the sshfs command-line tool in /usr/local/bin? Worked fine for me, and I notice this is also what Drew used for his example. I downloaded the sshfs.app, but found that I liked a simple shell script better.
Also noticed that a recent update to MacFUSE removes the requirement for /usr/local/bin to be in the PATH.