Difference between revisions of "Davfs2"

From ArchWiki
Jump to: navigation, search
m
(added a tip for using systemd mounting)
 
(74 intermediate revisions by 25 users not shown)
Line 1: Line 1:
[[Category:File systems (English)]]
+
[[Category:File systems]]
[[Category:HOWTOs (English)]]
+
[[Category:WebDAV]]
==Introduction==
+
[[ja:Davfs2]]
'''DAVfs''' is a Linux file system driver that allows you to mount a WebDAV server as a disk drive. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources, defined in RFC 4918.
+
[http://savannah.nongnu.org/projects/davfs2 davfs2] is a Linux file system driver that allows to [[mount]] a [[WebDAV]] resource. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources.
  
==Installing DAVfs==
+
== Installing davfs2 ==
Make sure the [extra] repo is enabled, then run:
 
# pacman -Sy davfs2
 
  
==Mounting the partition==
+
[[Install]] {{Pkg|davfs2}} from [[official repositories]].
Examples:
+
 
  # mount.davfs http://localhost:8080/ /mnt/dav
+
== Mount WebDAV-resource ==
# mount -t davfs http://localhost:8080/ /mnt/dav
+
 
 +
=== Configuration and mount options ===
 +
 
 +
There is a system wide '''configuration''' file {{ic|/etc/davfs2/davfs2.conf}} and a user configuration file {{ic|~/.davfs2/davfs2.conf}}. The latter is read in addition to the system configuration when invoked by an ordinary user and takes precedence. There are general, WebDAV related, cache related and debugging options.  All the available options and their syntax can be found in the [https://linux.die.net/man/5/davfs2.conf manual page].
 +
 
 +
There are also '''mount options''' used to define if needed the path of the configuration file, the owner and group of the filesystem and some other options related to file access. The list of recognised options can be obtained with the following command:
 +
$ mount.davfs -h
 +
 
 +
Also see {{man|8|mount.davfs}} for description and options.
 +
 
 +
=== Using command-line ===
 +
To mount a WebDAV-resource use {{ic|mount}}, not {{ic|mount.davfs}} directly.
 +
 
 +
  # mount -t davfs http(s)://addres:<port>/path /mount/point
 +
 
 +
=== Using systemd ===
 +
To use [[systemd#Mounting|systemd mounting]]:
 +
 
 +
{{hc|/etc/systemd/system/mnt-webdav-service.mount|<nowiki>
 +
[Unit]
 +
Description=Mount WebDAV Service
 +
After=network-online.target
 +
Wants=network-online.target
 +
 
 +
[Mount]
 +
What=http(s)://address:<port>/path
 +
Where=/mnt/webdav/service
 +
Options=uid=1000,file_mode=0664,dir_mode=2775,grpid
 +
Type=davfs
 +
TimeoutSec=15
 +
 
 +
[Install]
 +
WantedBy=multi-user.target
 +
</nowiki>}}
 +
 
 +
You can create an systemd automount unit to set a timeout
 +
{{hc|/etc/systemd/system/mnt-webdav-service.automount|<nowiki>
 +
[Unit]
 +
Description=Mount WebDAV Service
 +
After=network-online.target
 +
Wants=network-online.target
 +
 
 +
[Automount]
 +
Where=/mnt/dav
 +
TimeoutIdleSec=300
 +
 
 +
[Install]
 +
WantedBy=remote-fs.target
 +
</nowiki>}}
 +
 
 +
See [[Fstab#Automount with systemd]] for more tips and tricks when using systemd mount units.
 +
 
 +
=== Using fstab ===
 +
 
 +
To define how the webdav resource should be mounted into the filesystem, [[append]] a [[fstab]] entry under the following format:
 +
 
 +
{{hc|/etc/fstab|2=<nowiki>https:</nowiki>//''webdav.example/path'' /mnt/''webdav'' davfs rw,user,uid=''username'',noauto 0 0}}
 +
 
 +
where ''username'' is the owner of the mounted file system. It may be a numeric ID or a user name and only ''root'' can mount a uid different from the mounting user.
 +
 
 +
== Tips and tricks ==
 +
 
 +
=== Storing credentials ===
 +
 
 +
Create a ''secrets file'' to store credentials for a WebDAV-service using {{ic|~/.davfs2/secrets}} for ''user'', and {{ic|/etc/davfs2/secrets}} for ''root'':
 +
 
 +
{{hc|/etc/davfs2/secrets|
 +
2=<nowiki>https:</nowiki>//''webdav.example/path'' ''davusername'' ''davpassword''}}
 +
 
 +
Make sure the ''secrets file'' contains the correct [[permissions]], for ''root'' mounting:
 +
# chmod 600 /etc/davfs2/secrets
 +
# chown root:root /etc/davfs2/secrets
 +
 
 +
And for ''user'' mounting:
 +
$ chmod 600 ~/.davfs2/secrets
 +
 
 +
== Troubleshooting ==
 +
 
 +
=== Creating/copying files not possible and/or freezes ===
 +
 
 +
If creating/copying files is not possible and/or freezes occur, edit the [[#Mount_WebDAV-resource|configuration file]] to use {{ic|use_locks 0}} as option.
 +
Default for this parameter is {{ic|1}} which locks files on the server when they are opened for writing.
 +
 
 +
== See also ==
 +
 
 +
*http://ajclarkson.co.uk/blog/auto-mount-webdav-raspberry-pi/

Latest revision as of 19:50, 28 April 2018

davfs2 is a Linux file system driver that allows to mount a WebDAV resource. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources.

Installing davfs2

Install davfs2 from official repositories.

Mount WebDAV-resource

Configuration and mount options

There is a system wide configuration file /etc/davfs2/davfs2.conf and a user configuration file ~/.davfs2/davfs2.conf. The latter is read in addition to the system configuration when invoked by an ordinary user and takes precedence. There are general, WebDAV related, cache related and debugging options. All the available options and their syntax can be found in the manual page.

There are also mount options used to define if needed the path of the configuration file, the owner and group of the filesystem and some other options related to file access. The list of recognised options can be obtained with the following command:

$ mount.davfs -h

Also see mount.davfs(8) for description and options.

Using command-line

To mount a WebDAV-resource use mount, not mount.davfs directly.

# mount -t davfs http(s)://addres:<port>/path /mount/point

Using systemd

To use systemd mounting:

/etc/systemd/system/mnt-webdav-service.mount
[Unit]
Description=Mount WebDAV Service
After=network-online.target
Wants=network-online.target

[Mount]
What=http(s)://address:<port>/path
Where=/mnt/webdav/service
Options=uid=1000,file_mode=0664,dir_mode=2775,grpid
Type=davfs
TimeoutSec=15

[Install]
WantedBy=multi-user.target

You can create an systemd automount unit to set a timeout

/etc/systemd/system/mnt-webdav-service.automount
[Unit]
Description=Mount WebDAV Service
After=network-online.target
Wants=network-online.target

[Automount]
Where=/mnt/dav
TimeoutIdleSec=300

[Install]
WantedBy=remote-fs.target

See Fstab#Automount with systemd for more tips and tricks when using systemd mount units.

Using fstab

To define how the webdav resource should be mounted into the filesystem, append a fstab entry under the following format:

/etc/fstab
https://webdav.example/path /mnt/webdav davfs rw,user,uid=username,noauto 0 0

where username is the owner of the mounted file system. It may be a numeric ID or a user name and only root can mount a uid different from the mounting user.

Tips and tricks

Storing credentials

Create a secrets file to store credentials for a WebDAV-service using ~/.davfs2/secrets for user, and /etc/davfs2/secrets for root:

/etc/davfs2/secrets
https://webdav.example/path davusername davpassword

Make sure the secrets file contains the correct permissions, for root mounting:

# chmod 600 /etc/davfs2/secrets
# chown root:root /etc/davfs2/secrets

And for user mounting:

$ chmod 600 ~/.davfs2/secrets

Troubleshooting

Creating/copying files not possible and/or freezes

If creating/copying files is not possible and/or freezes occur, edit the configuration file to use use_locks 0 as option. Default for this parameter is 1 which locks files on the server when they are opened for writing.

See also