Linux: Mount WebDav-Share using fstab and davfs2
13.10.2016
Betriebssysteme
Attention: The content is slightly out of date. The information in the text could therefore no longer be correct.
This article describes a way to automatically mount a webdav share at boot by editing /etc/fstab on a debian based linux os like Ubuntu.
<localuser>
,<localusergroup>
: The username and group of the currently logged on local user<localdir>
: The directory where the webdav share should be mounted to<webdavurl>
: The URL of the webdav share
Setup davfs
sudo apt-get update
sudo apt-get install davfs2
# Add localuser to group davfs2
sudo usermod -aG davfs2 localuser
# Allow other users than root to mount davfs volumes
sudo dpkg-reconfigure davfs2
sudo sh -c 'echo "/mnt/localdir webdavusername webdavpassword" >> /etc/davfs2/secrets'
sudo mkdir /mnt/localdir
Setup /etc/fstab
gedit admin:///etc/fstab
/etc/fstab
...
webdavurl /mnt/localdir davfs rw,auto,user,uid=localuser,gid=localusergroup,_netdev 0 0
...
While root
is the mounting user, it is still possible to change the owner of
the file system. That is what options uid
and gid
are for.
Linking to your Home directory
You might want to see the webdav share in your Home directory:ln -s /mnt/<localdir> /home/<localuser>/WebDav
OwnCloud at DomainFactory
If your login attempt results inCould not authenticate to server: rejected Basic
challenge
you should consider adding some lines to the .htaccess
of
your ownCloud-Installation. The problem occures when PHP is operated in CGI-Mode.
.htaccess
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
...
Debugging
Messages ofdavfs2
should be prefixed with a time stamp and "mount.davfs".
grep -Eni "mount.davfs" /var/log/syslog
# optional, enables detailed davfs2 logging
sudo sh -c 'echo "debug most" >> /etc/davfs2/davfs2.conf'