Featured image of post Mounting WebDAV on Linux

Mounting WebDAV on Linux

This document provides a detailed guide on how to mount WebDAV shares on Linux systems using the davfs2 tool. It includes complete installation and configuration steps, security settings, automatic mounting methods, and solutions to common issues.

Mounting WebDAV on Linux

This document describes how to mount WebDAV shares on Linux systems using davfs2, with Ubuntu 24.04 as an example.

Installing davfs2

Run the following command in the terminal to install the davfs2 package:

1
2
sudo apt-get update
sudo apt-get install davfs2

During installation, you may be prompted whether to allow non-root users to mount WebDAV. You can use the arrow keys to switch to the “Yes” option.

Creating a Mount Point Directory

Create a directory to serve as the mount point:

1
sudo mkdir /mnt/webdav

Configuring davfs2

Edit the davfs2.conf file to configure davfs2. Open the configuration file:

1
sudo nano /etc/davfs2/davfs2.conf

Find the use_locks configuration option in the file and ensure its value is set to 0. This disables file locking, as some WebDAV servers do not support locking.

1
use_locks 0

Save and close the file (press Ctrl+X, then press Y, and finally press Enter).

Configuring the davfs2 secrets File

Create a secrets file to store the username and password for the WebDAV server. Run the following command in the terminal:

1
sudo nano /etc/davfs2/secrets

Add a line similar to the following, replacing it with your WebDAV server’s username and password:

1
http://your-webdav-url username password

Replace the content in the above line with your actual information:

  • http://your-webdav-url - Your WebDAV server address
  • username - Your username
  • password - Your password

Save and close the file.

Setting File Permissions

To ensure the password in the secrets file is secure, set the file permissions:

1
sudo chmod 600 /etc/davfs2/secrets

Mounting the WebDAV Share

Use the mount command to mount the WebDAV share to the previously created mount point:

1
sudo mount -t davfs http://your-webdav-url /mnt/webdav

Automatic Mounting on Boot (Optional)

If you need to mount automatically on boot, you can edit the /etc/fstab file:

1
sudo nano /etc/fstab

Add the following line:

1
http://your-webdav-url /mnt/webdav davfs user,noauto 0 0

Unmounting the WebDAV Share

When you need to unmount, run:

1
sudo umount /mnt/webdav
Facing the sea with spring blossoms.
Built with Hugo
Theme Stack designed by Jimmy