1 A quickstart for DIY types

Here we will describe how to install manually and try Fuse under FreeBSDremote. There are a lot of Fuse based filesystems – see http://fuse.sourceforge.net/wiki/index.php/FileSystemsremote. While many of them can be expected to work under FreeBSD as-is or with minor tweaks, here we will concentrate on one specific filesystem, sshfs. See also http://fuse.sourceforge.net/wiki/index.php/FileSystemsOnFreeBSDremote.

For most users, it is recommended to use the ports instead of using these instructions. Follow these instructions if you want to use a development snapshot or you want to tweak something (eg., port another Fuse based filesystem to FreeBSD), and you are looking for a starting point. Otherwise just install the sysutils/fusefs-sshfs port.

First of all, note that currently you will be able to perform a fully functional installation only on FreeBSD systems from the RELENG_6 or newer branch. (Userspace components can be compiled also on RELENG_5 systems.)

1.1 Get the sources

Here we will describe the case when you get all code from their respective SCM repositories. You should use snapshots from not earlier than 17th Nov, 2005. The first Fuse release with FreeBSD support is 2.5.0-pre2, released ad 9th Jan, 2006.

  • Get fuse and sshfs sources. First login into the Fuse Anoncvs service:
    cvs -d:pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse login
    
    (when you asked for a password, hit enter), then fetch the sources:
    cvs -z3 -d:pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse co -P fuse
    cvs -z3 -d:pserver:anonymous@fuse.cvs.sourceforge.net:/cvsroot/fuse co -P sshfs
    
  • You have to have the FreeBSD module.
    • If you read this document as a part of a snapshot of the module, you already have it.
    • Else if you read it online, you can expect these instructions to work with the latest committed code. Go to http://fuse4bsd.creo.huremote and check out the code from your preferred SCM.
    • Alternatively, you can download a release tarball from http://fuse4bsd.creo.huremote and use the version of this document which is bundled with the release.

1.2 Dependencies

1.3 Compilation

Each of the subsections below will assume that you are at the top of the respective source tree. The instructions below will assume you use a Bourne compatible shell.

We will do a non-privileged installation (I’d say that’s easier than set up a jail). Choose your installation path and set the FPREFIX variable to this value (be it an absolute path).

We will assume that you have put all three source trees in the same directory, and their top directories are named fuse, sshfs, and fuse4bsd, respectively.

1.3.1 Library (Fuse)

  • As CVS snapshots don’t ship with pre-generated instances of autotools related files, you have to generate them. Do it with
    ln -sf /usr/local/share/aclocal/libtool.m4 . &&
    ln -sfv `pkg_info -L 'gettext*' | grep /usr/local/share/aclocal/` . &&
    (export PATH=/usr/local/gnu-autotools/bin:$PATH &&
    libtoolize &&
    aclocal -I . &&
    autoheader &&
    autoconf &&
    automake -a)
    
  • Install fuse with
    ln -sf ../kernel/fuse_kernel.h include/ &&
    ./configure --prefix=$FPREFIX --with-pkgconfigdir=$FPREFIX/libdata/pkgconfig &&
    make &&
    make install
    
    (The pkgconfigdir setting is not necessary, it’s just for making the installation more “BSDish”.)

1.3.2 SshFs

  • Generate autotools files with
    ln -sf /usr/local/share/aclocal/pkg.m4 . &&
    (export PATH=/usr/local/gnu-autotools/bin:$PATH &&
    aclocal -I . &&
    autoheader &&
    autoconf &&
    automake -a)
    
  • Type
    PKG_CONFIG_PATH=$FPREFIX/libdata/pkgconfig/ ./configure &&
    make
    

1.3.3 Kernel module

  • Copy (or link) the kernel/fuse_kernel.h file of the Fuse source tree into the fuse_module directory.
  • Type make. If you want normal quantity of debug output (currently in the form of kernel messages), add DEBUG2G=1 to make‘s environment, if you want tons of debug output, addDEBUG=1 to the environment.
    You might want / need to make the module make use of the features enabled in your kernel config (like support for diagnostic tools like INVARIANTS, WITNESS). (You do need it, eg., if you enabled DEBUG_LOCKS which affects binary compatibility.) To make this happen, the simplest solution is adding a KERNCONF=<YOUR_CONF_HERE> parameter to your make arguments. This will work only if you used standard locations when you compiled the kernel. If that’s not the case, you can use the KERNCONFDIR parameter to explicitly specify the location of the config headers. For the currently running kernel this should be the path seen in the output of uname -v.

Congratulations, you have all components prepared!

1.4 Using the Fuse based ssh filesystem

Here we will show how to setup Fuse so that non-privileged users can use it, too (although it’s up to you if you want this).

As the superuser, do

kldload fuse_module/fuse.ko
sysctl vfs.usermount=1

You’ll have to act as a user belonging to the operator group, or set device permissions appropriately (cf.  2).

Pick your favourite ssh accessible account, say, it’s foo@bar.baz.

Go to sshfs’ directory. First prepare the mount:

mkdir -p ~/fuse &&
export LD_LIBRARY_PATH=$FPREFIX/lib/
export PATH=$FPREFIX/bin:$PATH

Now you can activate the filesystem with:

./sshfs foo@bar.baz: ~/fuse

This will start up the filesystem daemon, who will mount the home directory of the “foo” account at bar.baz on ~/fuse (using mount_fusefs). You can get it done vice versa, so that mount_fusefs will spawn the daemon:

mount_fusefs auto ~/fuse ./sshfs foo@bar.baz:

Here is also a more customized example:

MOUNT_FUSEFS_VERBOSE=1 \
 ./sshfs -o push_symlinks_in,idmap=user,reconnect -C  foo@bar.baz:/ ~/fuse

If it failed to work for some reason, you can perform the steps of mounting the filesystem manually by yourself. Eg., first type

FUSE_DEV_NAME=/dev/fuse0 ./sshfs foo@bar.baz: -d

and then on another terminal:

mount_fusefs /dev/fuse0 ~/fuse

(This will work only if the device /dev/fuse0 is not yet in use.)

When you have finished using the filesystem, there are several ways of taking it down. For example, you can simply

umount ~/fuse

However, for this to work, you need the filesystem daemon operating properly. Unmounting by device doesn’t rely on the daemon, so the following is more robust (assuming you mounted the device /dev/fuse0):

umount /dev/fuse0

Or you can kill the daemon (cf. kill(1)remote). Just before she exits, she will unmount the filesystem.

For finding out these parameters of a Fuse mount, see  2.

For more details on mounting, see mount_fusefs(8)remote.

1.5 Note on other filesystems

The above instructions will help you to try using other Fuse based filesystems on FreeBSD, but there is one issue you should be aware of.

The Fuse library API has went through several revisions. Currently the library maintains backward compatibility on Linux, but Fuse author Miklós Szeredi decided to support FreeBSD only starting with API revision 25 (not without reason: this is the first API revision which utilizes only POSIX/SUSV3 compatible interfaces, therefore alleviates platform dependecy issues filesystem authors have to face with).

For more information about the backward compatibility issue and the way of updating filesystems see the mailing list subthread starting from http://thread.gmane.org/gmane.comp.file-systems.fuse.devel/2310remote and subsequent posts. To cut the story short, your statfs method will have to be converted from using struct statfs to using struct statvfs (and take care about filling its f_frsize field). In most cases (ie., if your filesystem was using API 22) this will be enough, although it might be worth to take a look at the new feaures of API 25. (Note that API 23 and 24 just brought in extensions, so API 22 is a strict subset of these, with no compatibility issues.)

An overview of the API revisions of the Fuse library can be found at http://fuse.sourceforge.net/wiki/index.php/ApiChangelogremote.

Also see the following posts, with concrete examples of patches for (quick’n’dirty) API upgrade:

A more carefully coded example is provided by Fuse Python bindingsremote (after its resurrection in May-Jun 2006). Currently it supports all APIs from 22 to 26. It’s the suggested reference for getting around API compatibility problems.

1.6 Bugs

See the respective section of mount_fusefs(8)remote.

Prev Home Next
1 A quickstart for DIY types
1.1 Get the sources
1.2 Dependencies
1.3 Compilation
1.4 Using the Fuse based ssh filesystem
1.5 Note on other filesystems
1.6 Bugs
2 FAQ
3 Implementation notes about Fuse for FreeBSD, with special emphasis on comparing it to Linux Fuse