Mounting a WebDAV Cloud Drive on Linux with davfs2: Nutstore as an Example

WebDAV (Web Distributed Authoring and Versioning) is a technology that allows remote storage to be mounted into a local file system over the HTTP protocol. With it, you can run operations such as ls, cp, and mv on remote files just as you would on a local directory. This article explains how to install and configure davfs2 on Linux, using Nutstore as an example to demonstrate the full process of mounting a WebDAV directory.

1. Introduction

Nutstore is a commonly used cloud storage service that provides a WebDAV access interface. By using davfs2, we can mount Nutstore's remote storage directly to a local folder on Linux, making it possible to manage it in a way similar to a local disk.

2. Installing davfs2

1. Debian/Ubuntu Family

sudo apt update
sudo apt install davfs2

During installation, the system may ask whether to allow non-root users to mount WebDAV file systems. If you want regular users to be able to mount them as well, choose Yes or the corresponding option.

2. RHEL/CentOS/Fedora Family

sudo yum install davfs2

On newer Fedora / RHEL systems, you can also use:

sudo dnf install davfs2

3. Creating a Mount Point Directory

Create a local directory for mounting Nutstore, for example:

sudo mkdir -p /mnt/nutstore

This directory will serve as the mount point between the local system and Nutstore.

4. Configuring davfs2

4.1 Configuring Login Credentials

If Nutstore's WebDAV access requires a username and password, you can add the login information to /etc/davfs2/secrets:

sudo nano /etc/davfs2/secrets

Add the following line at the end of the file, replacing the sample URL, username, and password with your actual information:

https://dav.jianguoyun.com/dav  <your username>  <your password>

After saving, for security, make sure only root or the appropriate user can read the file:

sudo chmod 600 /etc/davfs2/secrets

4.2 Modifying davfs2.conf (Optional)

Some servers or cloud services may have incomplete WebDAV protocol support, causing errors such as:

mount.davfs: mounting failed; the server does not support WebDAV

In this case, you can try adding the following to /etc/davfs2/davfs2.conf:

ignore_dav_header 1

This option ignores certain protocol header checks, improving compatibility with some non-standard WebDAV services. Whether you need to enable it should depend on the actual behavior of your server.

5. Testing Manual Mounting

After configuration is complete, you can first test manual mounting. The following example uses Nutstore's WebDAV address. In some cases, you may need to add / to the end of the URL:

sudo mount -t davfs https://dav.jianguoyun.com/dav /mnt/nutstore

If everything is configured correctly, the system will prompt you for credentials or automatically read /etc/davfs2/secrets. After a successful mount, you can check it with:

df -h | grep nutstore
ls /mnt/nutstore

If remote files are listed, the mount was successful.

6. Automatic Mounting in /etc/fstab

If you want the system to mount it automatically at boot, or when running sudo mount -a, you can add the following entry to /etc/fstab:

https://dav.jianguoyun.com/dav  /mnt/nutstore  davfs  rw,uid=1000,gid=1000,_netdev,users,credentials=/etc/davfs2/secrets  0  0

Where:

  • rw: Mount in read-write mode.
  • uid=1000,gid=1000: Specify the owner and group of files after mounting. Adjust these according to your actual user ID and group ID.
  • _netdev: Indicates that this is a network file system, so the system will attempt to mount it after the network starts.
  • users: Allows non-root users to mount and unmount it.
  • credentials: Specifies the file that stores the WebDAV login credentials.

After adding the entry, test it with:

sudo mount -a

If there are no errors and /mnt/nutstore can be accessed normally, automatic mounting has been configured successfully.

7. Common Issues and Solutions

1. the server does not support WebDAV

  • Confirm that Nutstore or the other server has WebDAV enabled and that the URL is correct. If necessary, try adding / at the end.
  • Try adding ignore_dav_header 1 to /etc/davfs2/davfs2.conf.
  • Check that the network connection is working and that no firewall or proxy is blocking access.

2. Frequent Username or Password Prompts

  • Make sure /etc/davfs2/secrets is configured correctly and that its permissions are set to 600.
  • If using user-level configuration, you can instead save credentials in ~/.davfs2/secrets, with the same restricted file permissions.

3. Permission Issues

  • If you cannot read or write files after mounting, check the uid and gid options in /etc/fstab, or add the user to the davfs2 group.
  • Adjust the permissions of the mount point directory and local cache directory according to your actual needs.

4. Network Startup Order

  • The _netdev option tells the system to mount after the network is ready.
  • If startup order problems persist, consider using a systemd mount unit and setting dependencies such as After=network-online.target.

5. Alternatives

If Nutstore's WebDAV is incompatible or unstable in your environment, you can use tools such as rclone to mount or sync through their WebDAV support.

8. Summary

With davfs2, you can mount cloud drive services that support WebDAV, such as Nutstore, to a local Linux system and get a file operation experience close to using a local disk. If you encounter non-standard WebDAV implementations or connection issues, you can try ignore_dav_header 1, or use other tools such as rclone to assist with mounting.

Once configured correctly, the system can automatically load the remote storage at startup, and users can access, edit, and manage cloud files at any time without manually logging in through a web page or relying on an additional sync client. This is practical for scenarios such as multi-platform file management and remote work on servers.

Further Reading and References:

Leave a Reply