Problem
If you used Nextcloud before, I'm sure you are aware of their sync client. Simply select which folders you want to sync and it will copy the files down to your computer and make sure any changes are kept in sync. Just like the sync client of any other storage provider (e.g. Google Drive, Dropbox).
However, if you have a lot of data on Nextcloud, have very little free space on your computer, or cannot run the sync client for some reason, can you still leverage Nextcloud?
Solution
That is where the WebDav
protocol comes in. (wikipedia)
The basic concept is that you can use a Nextcloud folder as if it were a remote hard drive. You can mount and use it on your computer just like any other drive.
Once it's mounted, you can read and write files to your Nextcloud server just like you would to any folder on your computer. All without having to sync everything down and run the sync client.
Details
Here I break down the process of mounting a Nextcloud server as a folder on your machine.
1. Installation
For this to work, you need a piece of software to convert the WebDav
protocol into something your computer can mount as a folder: davfs2
.
You can find documentation for davfs2
on archlinux
If you are running an up-to-date debian-based systen, davfs2
should be in the default repositories.
sudo apt install davfs2
During installation, select the option to allow unpriviledged users to mount resources. This avoids some permission issues.
2. Find WebDav Link
Next you need to find the WebDav
link you want to use. Nextcloud shows this information in the sidebard under Settings:
You can use the link for any folder. You can mount your entire account, or just one particular folder.
3. Mount Folder
Finally, run the mount command to mount it to a local folder:
mkdir Nextcloud/
sudo mount -t davfs <WebDav path> Nextcloud/ -o uid=1000
You will be prompted for your Nextcloud username and password.The mount command needs to be run as root
, but by proving the uid=
option, the mounted files are "owned" by the provided user ID. Use the user ID of your account to allow you to easily modify them.
Your user ID will likely be 1000
, but you can check with the id
command.
This allows you to have your entire Nextcloud instance available as a regular folder on your computer, all without taking up any disk space!
This can be useful for a few use-cases:
- You have very limited disk space on the client
- You cannot/will not use the Nextcloud sync tool (e.g. on a headless system)
The main drawbacks are availability and performance. Your files will only be available when you can connect to the Nextcloud server, and read/write performance will never be as good as having the files actually saved on your computer.