I've just installed nextcloud on Ubuntu 16_04, using snap. If I try to add a local directory as an external storage, I get
stat(): stat failed for /data/test/ at /snap/nextcloud/5119/htdocs/lib/private/Files/Storage/Local.php#140
This happens both with version 12 and 13.
I'm working with a test directory that is readable and writable by everyone:
>ls -lad /data/test
drwxrwxrwx 2 www-data 4096 Feb 17 13:50 /data/test
I've tried several other directories, including ones on the same filesystem as the snap, in case this makes a difference.
External Storage setup is as follows:

DB info is:
>sudo nextcloud.occ files_external:list
+----------+-------------+---------+---------------------+-------------------------+---------+------------------+-------------------+
| Mount ID | Mount Point | Storage | Authentication Type | Configuration | Options | Applicable Users | Applicable Groups |
+----------+-------------+---------+---------------------+-------------------------+---------+------------------+-------------------+
| 5 | /test | Local | None | datadir: "\/data\/test" | | All | |
+----------+-------------+---------+---------------------+-------------------------+---------+------------------+-------------------+
It seems a bit like the problem I had. Don't know if it will help but here is what i did:
Thanks @Seferi, that works.
Glad I could help!
Thanks @Seferi, you're on top of things!
Could I suggest that a message that "Only directories in /media can be mounted as external storage" would save future users a lot of time? The restriction is not immediately clear, and it's a slightly strange workaround for a fairly reasonable use case.
The solution with removable-media is very easy and works excellent. However, this makes it possible to mount (probably) all removable media / all mounts from within Nextcloud as root, which is something I didn't like. However, this is how I did it in the end:
sudo mkdir /var/snap/nextcloud/common/nextcloud/data/myUsername/files/Datasudo mount -B /what/i/want/in/my/Nextcloud /var/snap/nextcloud/common/nextcloud/data/myUsername/files/DataData, and Nextcloud found the mounted folder.Sorry to bring up this old thread.
I am just wondering, is this error and workaround only related to removable-media (as in an external USB drive or what ever)? Or does it apply so S3 storage as well? I am getting this error once in a while, and my data is on S3 storage connected via external storage.
EDIT:
Ubuntu 18.04
Nextcloud 15 (snap, obvious)
I am just wondering, is this error and workaround only related to removable-media (as in an external USB drive or what ever)? Or does it apply so S3 storage as well? I am getting this error once in a while, and my data is on S3 storage connected via external storage.
I seriously have no Idea about how S3 storage can be integrated into a Nextcloud snap, sorry. This workaround was for removable media as well as partitions outside the partition where the snap is installed on. And, in my case, this isn't something that occurs more than one time. If it works, it just works.
I am just wondering, is this error and workaround only related to removable-media (as in an external USB drive or what ever)? Or does it apply so S3 storage as well? I am getting this error once in a while, and my data is on S3 storage connected via external storage.
I seriously have no Idea about how S3 storage can be integrated into a Nextcloud snap, sorry. This workaround was for removable media as well as partitions outside the partition where the snap is installed on. And, in my case, this isn't something that occurs more than one time. If it works, it just works.
The external storage app supports S3. I should hope that it is in fact supported, why wouldnt it?
The external storage app supports S3. I should hope that it is in fact supported, why wouldnt it?
Sorry, I've just tried to state that I'm not familiar with S3 and do not know how it works. Therefore, I don't have any idea whether this workaround works for S3 or not.
Sadly I'm not familiar with how the S3 storage works either, but I see no reason why it wouldn't be supported-- it just stores things using a network API instead of on disk, which should have no confinement issues. @JakobPP, can you open a new issue please and we can discuss there?
It seems a bit like the problem I had. Don't know if it will help but here is what i did:
- connected the removable-media plug with : sudo snap connect nextcloud:removable-media
- bind mounted the /data/test to /media/nextcloud : sudo mount -o bind /data/test /media/nextcloud -
- added it to fstab so it stays after reboots: /data/test /media/nextcloud/ none bind
- afterwards added the /media/nextcloud as external storage in nextcloud web interface.
Thanks @Seferi , your instructions helped me to finally get my external hdd working properly! I didn't need to do step 1 though since the Pi is already connecting with the external hdd automatically.
Most helpful comment
It seems a bit like the problem I had. Don't know if it will help but here is what i did: