dcsimg

Accessing WebDAV as a Filesystem With davfs2

By Juliet Kemp (Send Email)
Posted Jul 19, 2010


More about open source software

Most admins know WebDAV, but davfs2 isn't as well known. With this open source software tool, you can connect to WebDAV server as a regular filesystem, thus allowing applications that don't support WebDAV to access shared resources via WebDAV.

I had a request this week to check out davfs2. This neat open source utility allows you to connect to a WebDAV server as a regular filesystem, meaning that applications that don't support WebDAV can still access resources shared via WebDAV. Basically, it provides another protocol for mount to use.

davfs2 is available as a Debian/Ubuntu package, so it's easy to install with apt-get install davfs2. Once installed, you can connect via the commandline straight away, if you have sudo access:

sudo mount -t davfs http://webdav.example.com/directory /mnt/

This will mount the specified WebDAV share at /mnt. You'll be asked for the username and password to connect with, if the share is secured. When you're done, unmount with

sudo umount /mnt

This isn't entirely convenient, though; it's better to be able to mount the directory as a normal user. Edit

/etc/fstab
to set up a mountpoint by adding a line like this:
http://webdav.example.com/directory /home/juliet/mnt/webdav davfs rw,noauto,user 0 0

You'll need to create the mountpoint with

mkdir -p /home/juliet/mnt/webdav

if it doesn't already exist.

If you try running mount

/home/juliet/mnt/webdav
now, as a non-root user, you'll be told that
/sbin/mount.davfs
is not setuid root. Fix this by running

sudo dpkg-reconfigure davfs2

and answering 'yes' to the setuid question. You'll also need to add your user to the davfs group (either

edit /etc/group
or use sudo gpasswd -a username davfs). Log out and in again to update the group information.

Now try mount

~/mnt/webdav
again. You'll be challenged for the username and password (if the share is protected), after which you should be able to access your directory just as you would any other mounted directory.

Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.