Here we will describe how to install manually and try
Fuse
under
FreeBSD.
There are a lot of Fuse based filesystems – see
http://fuse.sourceforge.net/wiki/index.php/FileSystems
.
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/FileSystemsOnFreeBSD
.
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.)
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.
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
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.
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)
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”.)
ln -sf /usr/local/share/aclocal/pkg.m4 . && (export PATH=/usr/local/gnu-autotools/bin:$PATH && aclocal -I . && autoheader && autoconf && automake -a)
PKG_CONFIG_PATH=$FPREFIX/libdata/pkgconfig/ ./configure && make
kernel/fuse_kernel.h
file of the Fuse
source tree into the fuse_module
directory.
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.
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!
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)).
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).
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/2310
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/ApiChangelog.
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
bindings
(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.
See the respective section of
mount_fusefs(8).