electronic.alchemy :: Using FUSE
where the past meets the future
smartos > Using FUSE

Using FUSE

Created by hww3. Last updated by hww3, 82 days ago. Version #6.

Filesystem in Userspace (FUSE) is a mechanism that permits filesystems to be added as user-space programs, without needing to write kernel code. Support for a number of useful filesystems are available as FUSE programs(?). OI has bundled a FUSE driver and some fuse based filesystems, but most of the other illumos variants don't include this. I've put together a patch for Joyent's SmartOS that includes the necessary components for using FUSE filesytems both in the global zone and your own native zones.

The necessary components for using FUSE filesystems are the FUSE kernel driver, libfuse and its assorted header files, and a set of programs for mounting and unmounting FUSE filesystems. You'll need a platform image built with these components, which is available here:


Next, you'll need a FUSE filesystem program. I'll demonstrate using sshfs. Create a new native zone (in this case, I'm using the base64-trunk image)

In order to use FUSE in our new zone, we need to share the fuse device with the zone, and grant the zone permission to mount fuse filesystems.

globalzone# zonecfg -f MYZONEUUID << EOF
add device
set match=/dev/fuse 
globalzone# vmadm update MYZONEUUID fs_allowed="fuse"
globalzone# vmadm reboot MYZONEUUID

Now, we can build and test the sshfs FUSE filesystem in our zone:

myzone# pkgin -y install build-essential glib2
myzone# git clone https://github.com/alhazred/illumos-sshfs
myzone# cd illumos-sshfs/sshfs-fuse/
myzone# vi sshfs.c # comment out the line with "g_thread_init()"
myzone# SSHFS_CFLAGS="-I/usr/include/fuse -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include" SSHFS_LIBS="-lfuse -lglib-2.0 -lxnet" ./configure
myzone# make
myzone# mkdir /tmp/sshfs-test
myzone# ./sshfs user@host:/path /tmp/sshfs-test
myzone# test out your filesystem
myzone# umount /tmp/sshfs-test

We can use illumos FUSE filesystems in LX zones if the prerequisites are available. The following steps describe how to do this.

FUSE for illumos uses pfexec to grant mount permission for non-root users when permitted. LX doesn't have pfexec, so we can put a "dummy" pfexec in the path and it will get used. We also need to make the filesystem utilities available where they're expected in the filesystem, and we can do this with a symbolic link.

mylxzone# ln -s /native/usr/lib/fs /usr/lib/fs
mylxzone# vi /tmp/pfexec

  exec $*

mylxzone# chmod 755 /tmp/pfexec

Now, we can try to use our native sshfs. As a quick and dirty example of this, copy the illumos native sshfs binary to our new lx zone (in our case, we'll just put it in /root). We'll also need the shared libraries, which we'll copy from /opt/local/lib to /root:


mylxzone# PATH=$PATH:/tmp:/native/usr/bin ./sshfs user@host:/path /tmp/sshfs-test

Not categorized | RSS Feed | BackLinks

comments powered by Disqus