Access Nextcloud from your Raspberry Pi

When I got my first shiny RPi4, the most pressing issue was the low storage capacity of the SD card. How do you get quick access to all your files?

One solution would be to mount an external hard-drive. Or you could connect to a network-attached storage (NAS) device, if you have one. Another option is to use cloud-based services on the internet.

Of course there are a ton of cheap cloud providers out there, most of them proprietary, but I’m not a big fan of handing all my important data over to Google and friends. Instead, I set up a self-hosted version of Nextcloud a few years ago and I keep most of my files there. At least the ones I need quick access to.

Unfortunately, Nextcloud doesn’t offer a desktop client for Raspbian and it’s quite tedious to transfer files through a browser. But the documentation describes several alternative solutions, among them to access Nextcloud files using WebDav.

Configuring your RPi doesn’t take very long and usually works quite well. If you’d like to give it a try, I have copied my own setup instructions below. Issues that I ran into when trying this setup are noted in the Troubleshooting section below. Feel free to leave a comment if you found any more!

Mounting a Nextcloud share with WebDAV

Make sure your system is up to date.

sudo apt-get update
sudo apt-get upgrade

You will need to install the davfs2 WebDAV filesystem driver to be able to mount WebDAV shares on a remote filesystem.

sudo apt-get install davfs2

A window to configure davfs2 will open, confirm with yes that unprivileged users should be able to mount WebDAV resources

Add your user to the davfs2 group. I’m using the standard user ‘pi’ as an example.

sudo usermod -aG davfs2 pi
sudo usermod -a -G pi davfs2

Then create a nextcloud directory in your home directory (usually this is /home/pi) for the mountpoint, and a .davfs2/  directory for your personal configuration file:

mkdir nextcloud
mkdir .davfs2

Next you have to copy the secrets folder from /etc/davfs2/secrets into your home/pi/.davfs2/secrets directory. This might need root privileges so if a simple sudo does not work, type sudo su first.

sudo cp /etc/davfs2/secrets /home/pi/.davfs2/secrets

Set yourself as the owner and the permissions to read-write. Ensure you are still in the /home/pi folder.

sudo chown pi:pi /home/pi/.davfs2/secrets
sudo chmod 600 /home/pi/.davfs2/secrets

Now open the secrets file (I’m using nano, but feel free to use any editor you prefer).

sudo nano /home/pi/.davfs2/secrets

Add your Nextcloud login credentials to the end of the file. I’m using the following format, which worked well for me but the documentation also has other suggestions. <username> <password>
/home/user/nextcloud <user> <password>

Open the fstab file. This might need root privileges again.

sudo nano /etc/fstab

Add the mount information to /etc/fstab. This is a bit of a tricky step and you should use the exact template you see here, replacing it with your paths and username as needed. If this information is not correct, any boot issues with fstab might cause your root account to lock. In that case the RPi can no longer be booted. Read the troubleshooting section if this happened to you. /home/pi/nextcloud davfs noauto,user,rw 0 0

Test the mount and authentication with this command. You should not need root privileges for this step and the server should now ask you for username and password.

mount /home/pi/nextcloud

Now every time you login to your Raspberry Pi, the Nextcloud share should automatically mount via WebDAV in your nextcloud folder and get access to the files as soon as you click on it.


  • I have restarted my RPi but now it won’t boot and an error message states that the root account is locked.

You have entered a faulty information into your fstab file. Whenever this issue came up for me, it was because I did not add noauto in the fstab file. The official Nextcloud documentation actually refers to using auto, but for some reason this does not work well for the RPi. Get your RPi fixed using this very helpful solution here and then change fstab to include the correct path.

  • When trying to mount I’m getting an error message that the server does not support locks.

Open the davfs2.conf configuration file and add use_locks 0

sudo nano /etc/davfs2/davfs2.conf
use_locks 0
  • Why can’t I change anything in my Nextcloud folder?

If you can mount your Nextcloud folder but you cannot write to it, there is an issue with permissions. Your Nextcloud folder is probably owned by root – change permissions to pi like this and ensure you have writing privileges:

sudo chown -R pi:pi nextcloud/
sudo chmod 755 nextcloud/
  • How do I unmount the share?

Use the following command in the terminal:

umount ~/nextcloud

1 thought on “Access Nextcloud from your Raspberry Pi”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.