Mount WebDAV remote storage in Fedora Linux using davfs2 driver

Feb 5, 2017 Linux, Storage

Mount WebDAV remote storage in Fedora Linux using davfs2 driver
WebDAV (Web Distributed Authoring and Versioning) is an extension of the Hypertext Transfer Protocol (HTTP) that allows clients to perform remote Web content authoring operations. The WebDAV protocol provides a framework for users to create, change, copy, move, lock and version the files on a server, typically a web server or web share. This type of protocol is used by some hosting providers (like my favorite HostUpon) in cPanel software, to provide quick and easy access to the files stored in hosting account disk space.

In this tutorial we are mounting remote WebDAV resource in Fedora release 24 via davfs2 file system driver.


1. Install davfs2 file system driver

[root@tuxfixer ~]# dnf install davfs2

2. Configure davfs2 group membership

Along with the package installation, davfs2 group should be created in /etc/group.
Add yourself to davfs2 supplementary group in order to be able to use WebDAV resources as regular user:

[root@tuxfixer ~]# usermod -aG davfs2 gjuser

Verify membership in davfs2 supplementary group:

[root@tuxfixer ~]# groups gjuser
gjuser : gjuser wireshark vboxusers davfs2

3. Mount WebDAV server in Linux file system

Create WebDAV mount point:

[root@tuxfixer ~]# mkdir /mnt/webdav

Mount WebDAV storage in mount point using your credentials (username/password):

[root@tuxfixer ~]# mount -t davfs /mnt/webdav

Verify mounted WebDAV storage:

[root@tuxfixer ~]# df -hT
Filesystem                    Type      Size  Used Avail Use% Mounted on
devtmpfs                      devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs                         tmpfs     3.9G   23M  3.9G   1% /dev/shm
tmpfs                         tmpfs     3.9G  1.7M  3.9G   1% /run
tmpfs                         tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sdb1                     ext4       61G   26G   32G  45% /
tmpfs                         tmpfs     3.9G  3.4M  3.9G   1% /tmp
/dev/sda1                     ext4      917G  257G  614G  30% /var/lib/libvirt/images
/dev/sdb3                     ext4      250G  217G   20G  92% /home
tmpfs                         tmpfs     799M   16K  799M   1% /run/user/42
tmpfs                         tmpfs     799M   48K  799M   1% /run/user/1000   fuse      1.3T  763G  509G  61% /mnt/webdav

Now unmount WebDAV storage:

[root@tuxfixer ~]# umount /mnt/webdav 
/sbin/umount.davfs: waiting while mount.davfs (pid 5770) synchronizes the cache .. OK

4. Mount WebDAV server using fstab (optional)

Add WebDAV related entry to your /etc/fstab file:

# /etc/fstab
# Created by anaconda on Sun Jun 22 20:42:18 2014
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
UUID=ef15b875-ee2a-4def-8e16-a3ccdb41ff36 /                       ext4    defaults        1 1
UUID=5279bdb7-aecb-4bb2-9a54-d7d042f70e6c /home                   ext4    defaults        1 1
UUID=ae344cef-02bd-41a0-9ae5-a65ca9b473a8 /var/lib/libvirt/images ext4    defaults        1 1
UUID=087470ac-4819-44cb-81df-9980fd601a73 swap                    swap    defaults        0 0               /mnt/webdav             davfs   user,noauto     0 1

Note: option noauto is set on purpose to avoid potential problems with booting the client system, in case WebDAV server wasn’t accessible during that time

Now login as regular user and create password file in your home directory:

[gjuser@tuxfixer ~]$ mkdir ~/.davfs2/
[gjuser@tuxfixer ~]$ echo " your_login your_password" >> ~/.davfs2/secrets 
[gjuser@tuxfixer ~]$ chmod 0600 ~/.davfs2/secrets

Mount WebDAV server as regular user:

[gjuser@tuxfixer ~]$ mount /mnt/webdav

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.