"Your data directory is not writable" keeps recurring

I’m running Nextcloud 20, installed via snap on Ubuntu 20.04.

I’m storing the data on an separate hard drive mounded at /media/nextcloud/data/

I’ve run snap connect nextcloud:removable-media and Nextcloud runs fine until it eventually displays the “Your data directory is not writable” error.

To fix this I’ll do the following:

Switch to root:
sudo -i

Stop nextcloud:
snap stop nextcloud

Unmount and remount the hard drive (or I can’t change permissions):
umount /media/nextcloud/data
mount -o rw /media/nextcloud/data/

Change permissions and owners:
chmod -R 0770 /media/nextcloud/data/
chown -R root:root /media/nextcloud/data/

Start nextcloud
snap start nextcloud

Perform a file check:
nextcloud.occ files:scan --all

and everything will work again, but at some random time in the future, I’ll get the “Your data directory is not writable” error again.

Is there anything I should be looking at to diagnose why this issue keeps coming back?

all permissions must be given to the user www-data and the group www-data:
(example) chown -R www-data:www-data /media/nextcloud/data/
Thiis must also include every subdirectory in this directory.
The handling of data used for programms allowing to send Data outside the system, should never be handeld by the root user.


I discovered what was occurring by browsing dmesg.

The drive in question is an ext4 file system and had an aborted journal which caused the drive to be mounted read only. This was triggering the “Your data directory is not writable” error.

I have now repaired the journal and rebooted the computer several times, and so far seems to be working.

If I continue to have journaling problems, I’ll have to move the data to another, more reliable drive, and retire the current one.

Unfortunately, when you install Nextcloud via Snap, the root user is the server.

You can’t use:

chown -R www-data:www-data /media/nextcloud/data/

It’s a limitation of using the snap installer version.

Worked for me. Thanks.