After Nextcloud broke the Linux desktop client for NTFS filesystems (see #7613), I tried to switch from syncing my folders to simply mounting them via WebDAV. On Linux, the official to accomplish this uses the davfs2
driver. Unfortunately, due to some long-lasting issue with that driver, directory listings are unbearably slow, though. Different mount options or driver parameters (like adapting caching- and locking behavior, etc.) didn’t help for me.
Eventually, I found a good solution, which uses rclone in place of the davfs2
FUSE driver for the mount. Apparently, their WebDAV implementation is more robust and has better performance (orders of magnitude faster in my case), at least in case of a Nextcloud remote. While rclone’s primary purpose is backups, it is well suitable for my very simple use case as well. Besides common storage services like S3, Google Cloud Storage, Dropbox and countless others, rclone has a WebDAV backend, which allows to create a local mount point from a WebDAV resource. Here is how:
Setup
Install rclone
Configure a new remote for Nextcloud WebDAV
Mount it manually (to verify things are working)
1
rclone mount nextcloud: /mnt/nextcloud --vfs-cache-mode full
Note: Your mount point can vary from
/mnt/nextcloud
, of course.Create a systemd service for auto-mounting
Create a new file at
/etc/systemd/system/rclone-nextcloud.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33[Unit]
Description=RClone mount for Nextcloud
Documentation=man:rclone(1)
After=network-online.target
Wants=network-online.target
AssertPathIsDirectory=/mnt/nextcloud
[Service]
Type=simple
User=your-username
Group=your-groupname
ExecStart=/usr/bin/rclone mount nextcloud: /mnt/nextcloud \
--config=/home/your-username/.config/rclone/rclone.conf \
--vfs-cache-mode full \
--vfs-cache-max-age 1h \
--vfs-cache-max-size 1G \
--buffer-size 16M \
--dir-cache-time 72h \
--umask 002 \
--uid 1000 \
--gid 1000 \
--daemon-timeout 30s
ExecStop=/bin/fusermount -u /mnt/nextcloud
TimeoutStartSec=60
TimeoutStopSec=20
KillMode=process
Restart=on-failure
RestartSec=30
StartLimitInterval=300
StartLimitBurst=3
[Install]
WantedBy=multi-user.targetImportant: Replace
your-username
andyour-groupname
by your actual user- and group names and adaptuid
andgid
accordingly. Also, feel free to experiment with different VFS caching options.Start the service and enable it for being executed during startup
sudo systemctl daemon-reload && \ sudo systemctl start rclone-nextcloud.service && \ sudo systemctl enable rclone-nextcloud.service
Note that if you’re using a custom DNS resolver (like dnscrypt-proxy in my case) or anything else that must be running before your Nextcloud remote can be reached, you’ll have to adapt the After=
and Wants=
options.