MacFUSE: sshfs for your mac

MacFUSE is a implementation of FUSE (File-system in USErspace) that is provided via a kernel extension.

So what is FUSE?

FUSE provides a easy way for anyone to create their own filesystem through providing hooks into the kernel. A list of FUSE filesystems tested with MacFUSE is provided on the wiki. One of most well known FUSE filesystems is SSHFS (A filesystem that runs over SSH + SFTP) so we'll use that as an example of MacFUSE in action.

Installing MacFUSE

The easiest way to get macfuse running on your mac is to go and grab the dmg that contains an installer that will install the kernel extension and required libraries. The package is available here on code.google.com. After installation you will need to restart your machine.

UPDATE: The most recent versions bundle sshfs as a separate download. If you want to install sshfs then you need to install the MacFUSE core as above and then install the separate sshfs package. The main difference is that if you want to use the comand line version as described below you need to symlink to the sshfs binary in the sshfs.app that you will have dropped into your applications directory. To do this simply type: sudo ln -s /Applications/sshfs.app/Contents/Resources/sshfs-static /usr/local/bin/sshfs Note if you have a sshfs binary already installed it's recommend you do use the symlink so that you are using an up to date version of the sshfs binary. As the gets updated so will your binary. (I would suggest renaming the old binary first before creating the symlink).

Currently it's necessary to make sure that /usr/local/bin is in your path. To check this open terminal and type echo $PATH. If /usr/local/bin isn't in the output of that command you will need to add it into your .bashrc file. Open/create .bashrc with your favorite command line text editor and add a line like this:

export PATH=$PATH:/usr/local/bin/

To pickup the changes simply close and reopen terminal or run the following command:

. ~/.bashrc

Testing MacFUSE

To make sure macfuse is working we can mount a remote server via SSHFS. To do this you'll need a remote server with SSH and the SFTP extension installed.

The command to run sshfs to mount a server filesystem is as follows:

mkdir /mountpath 
sshfs user@server:/remotedirectory/ /mountpath -oping_diskarb,volname=volumename

Replace "remotedirectory" with the directory on the remote server you want to mount and "mountpath" with the directory on your mac to use as a mount point. Replace volname with the name you want to use to represent the volume as in finder.

If it's worked you should see the volume show up in the finder. If not and you see a message like, "Remote system disconnected" then try running the same command again with this debug switch after sshfs:

-o sshfs_debug

In some cases if there's any problems relating to the connection this might help.

To unmount the filesystem simply eject the volume in Finder, or run:

umount /mountpath
Show Comments