Sharing files with wdfs and FUSE

1595

Author: Nathan Willis

I move from computer to computer constantly — desktops, laptops, testing machines — and rather than worry about synchronizing the assorted hard disks content, I prefer to keep one central copy of my documents that I can access anywhere. I do that using wdfs, the WebDAV file system for FUSE.

Keeping one set of files means never worrying about synchronization and merging. Changes never get unknowingly overwritten, and I have a single, simple backup strategy.

WebDAV is the Distributed Authoring and Versioning extension to HTTP. On Apache systems it is usually implemented with mod_dav, and many Web hosting companies provide it as an option, giving you a simple “flip a switch” path to run your own WebDAV server. WebDAV can run over HTTPS, providing a layer of security, and it requires setting up its own username/password combo for each user — distinct from any other server accounts or .htaccess — so you can even set up different WebDAV accounts for each machine you use and meticulously track changes.

But I’ll skip explaining the WebDAV server setup; first of all, plenty of excellent information is out there already, and second, the beauty of wdfs is that the FUSE module abstracts the details away. Once your WebDAV server is set up, wdfs can mount it directly into a Linux filesystem, including automatically mounting it at startup.

Insert your own “light the fuse” joke here

To start using wdfs, you must first install FUSE. FUSE is widely supported these days, so an official package from your Linux distribution is probably available. If you have not used FUSE before, though, you will need to ensure that it is properly configured.

FUSE uses the fuse group to determine which users are allowed to mount and unmount FUSE filesystems, so add yourself to the fuse group with sudo usermod -a -G fuse yourname. Load the FUSE kernel module with sudo modprobe fuse.

If your Linux distribution does not provide a wdfs package, you can grab the latest tarball from the project’s Web site. In addition to FUSE itself, the only special dependency is neon, a WebDAV client library. wdfs should compile and install with a basic ./configure; make; sudo make install.

With wdfs compiled and installed and the FUSE module loaded, make a local directory in which to mount the remote WebDAV share. The basic mount command is wdfs http://mywebdavserver.biz/foo ~/thelocalmountpoint -o username=nate -o password=natessecretpassword. As is the case in Web browsers, you can use https:// URLs if the remote share uses HTTPS, and you can append a port number after a colon if the server is not running on the standard HTTP or HTTPS port.

If you are using wdfs for collaborative editing, you can activate file locking on the share by adding -o locking=n to the above command. n can be 0, 1, 2, or 3. The default is mode 0, which uses no file locking. Mode 1 is the simplest; it locks a file when it is opened and unlocks it when it is closed. Mode 2 keeps the lock open until the file has been written and closed, and mode 3 keeps the file locked until either the share is unmounted or a specified timeout is reached. By default that timeout is five minutes, but you can alter it with the option -o locking_timeout=number_of_seconds.

Subversion users can add the -o svn_mode option, which activates a special Subversion mode used to access file revisions. Other options include -o accept_sslcert to automatically accept the remote site’s SSL certificate, and -o no_redirect to prevent being redirected by the remote Web server. Both of these could be useful if you script some wdfs activity that needs to work without user intervention.

Manually mounting with wdfs is fun, but if you plan use the same share regularly you will want to automount it. Just add a line to /etc/fstab of the form wdfs#http://mywebdavserver.biz/foo /mnt/thelocalmountpoint fuse users 0 0. you can specify comma-separated wdfs options (such as ,username=nate,password=natessecretpassword,acceptsslcert) directly after users in the fstab entry to automount the process entirely.

wdfs compared

When it is up and running, using a wdfs share is little different than using a local filesystem. The only noticeable distinction is the slower write speed, a hindrance shared by every WebDAV implementation and every remote filesystem.

One reason I prefer wdfs to other WebDAV methods is that you can push so much of the configuration details out of sight. The GNOME and KDE file managers can mount WebDAV shares, but using their GUI tools requires presence at the keyboard and logging in — neither of which is required if you mount the WebDAV share with wdfs via fstab.

There are other command-line WebDAV tools, such as cadaver, nd, and (for Emacs users) eldav. If you are only an occasional WebDAV user, those clients make sense. There is also an older WebDAV FUSE module named fusedav that could be useful if you have unexpected difficulty with wdfs.

A few years ago, I wrote about another FUSE-powered remote filesystem, sshfs, which offers many of the same benefits as wdfs, particularly if you can run your WebDAV server with SSL encryption. wdfs offers the benefit of working with a wide variety of commercial Web hosting services. All good Web hosts provide SSH access, of course, but by using WebDAV you can manage a share with a separate username and password from your main account, and share only a selected subdirectory of your account space, which is good from a security standpoint. Plus, you can easily access a WebDAV share from a Mac or Windows box, should the need arise.

Finally, there are application-level remote editing alternatives, such as gobby and the newly unveiled AbiCollab. These options allow for multi-user collaborative editing, which is excellent, but they are also designed for basic text and word processing and don’t support other document types.

Keeping everything on a local server that is shared over NFS works great for desktop and laptop machines around the house, but not as well for going on the road. And although modern Linux desktop environments all support WebDAV through their GUI file managers, utilizing WebDAV through the filesystem itself enables more applications, offers shell and script access, and is ultimately simpler to manage. If you are tired of syncing your files across multiple machines, save yourself time and headaches by looking into WebDAV and wdfs.

Category:

  • Internet & WWW