Hello all!
For those interested, the Chum repo now has davfs2 available.
davfs2 is a FUSE (Filesystem in Userspace) driver that allows you to mount remote network filesystems locally.
This is a small example guide how to set it up:
This guide assumes you have a Nextcloud (or other WebDAV server, e.g. SharePoint) and know your account information. We also use nemo
as the SFOS user in the examples, adjust for your default user ;).
1. Install the Chum repo:
there are various ways of doing that, in case you haven’t already follow the Guide here.
But basically it’s devel-su pkcon install -y sailfishos-chum && pkcon refresh
.
2. Install davfs2:
$ devel-su pkcon install -y davfs2
3. Create a mount point:
$ mkdir ${HOME}/mnt/cloud
4. Create a fstab entry (optional, but makes stuff convenient):
Use devel-su
to become root and edit /etc/fstab
. Add something like:
https://cloud.example.org/remote.php/dav/files/myusername/ /home/nemo/mnt/cloud davfs _netdev,user,noauto 0 0
Note the options at the end: _netdev,user,noauto
, these are important or your device might hang at boot or reboot.
5. Test
Basically you’re ready to mount things now, however at the moment only root
may do that. Try it:
$ devel-su
# mount /home/nemo/mnt/cloud
You will be prompted for username and password. If they are correct, you can now browse your files at the mounted location. (Obviously you need to be online for this to work)
Umnount again after testing:
$ devel-su
# umount /home/nemo/mnt/cloud
6. Add the user to the mount
group:
For reasons, davfs2 requires users to be in a dedicated group to be able to execute it. I have configured the package to use the mount
group for this. So add your user to that group:
$ devel-su gpasswd -a nemo mount
7. Log in anew:
Open a new Terminal, or ssh connection as user to pick up the group change. Doing id
should show that you are now member of the mount
group
8. Test again
As user, try the mount now, without devel-su
:
$ mount /home/nemo/mnt/cloud
Again, username and password prompt, and you can browse your files.
9. (Optional): Store authentication information:
You should now have a new directory at ${HOME}/davfs2
. Inside you have a file called secrets
. It allows you to store either username, username and password, or a client certificate for authentication. Follow the comments in that file and add you information.
/home/nemo/mnt/cloud myusername secretapppassword
It should be obvious that storing your password here is not a great idea. At least create an “app password” for your device on the server and use that, or if you can use revokable client certificates.
10. (Optional): Tune some settings:
There is also a file ${HOME}/davfs2/davfs2.conf
where you can tune things. Most of the defaults are fine, but I like doing these modifications:
# use a more XDG-compliant cache location:
cache_dir ~/.cache/davfs2 # per user cache
# tune for slow/bad network conditions
max_upload_attempts 25
dir_refresh 120 # seconds
delay_upload 20
cache_size 128 # MiByte
There is also the equivalent system-wide location at /etc/davfs2/
but you probably do not need to edit anything there.
Hope this is useful, good luck.
Some notes
Be careful when browsing the mounted directory. If your network is flakey or low-bandwidth, or high-latency, this may cause applications to hang while they try to browse stuff.
It may also be a good idea to add the mount to the blacklist of Tracker so it doesn’t try to index the remote files, but that is beyond the scope of this guide.
Oh, and the chum build is relatively new, if you find anything not working please feel free to bug me about it. Note that I have nothing to do with the software itself, I only package it.
References: