Snap install and external storage permission

Hello,

I have been fighting this problem for more than a week and have read a lot of topics, but my problem remains unsolved.

The problem is that the NC does not have the proper permission to acces the external storage added as local.
I get the Failed to open directory: Permission denied at /snap/nextcloud/35878/htdocs/lib/private/Files/Storage/Local.php#154

The HDD is mounted to /mnt/razmena folder and is not owned by root. It has 771 permission.
I could do the 777 and the NC would finaly see the files, but I am not about to give everyone access to it. Even then, the problem is back in the first subdirectory owned by anyone other than root.

The obvious beginner next step is to enable removable media with
sudo snap connect nextcloud:removable-media

Done with no luck. Restarted service, rebooted… No luck.

Little background on what I am using.
VM with ubuntu server installed on proxmox.
I had the exact same problem on debian VM

NC is version 26 installed via snap.

I would be able to accept defeat and admit I am doing something wrong if i didn’t have the exact same configuration on RPI raspbian. Using the very same HDD. I can swap the USB cable from server to RPI and the NC on RPI would see the files from /mnt/razmena. So obviously, the ownership and permissions are not the problem, it is the settings, but other than connecting removable media.
root does have access to the files and folders. I can access everything from webmin interface which is accessing everything as root. So seing files, rename, delete… can be done by root.
I have now just tried to add another drive, but this time, it was formated and file system was created on this machine. Just in case some permission is carried from the other system. Still no luck :frowning:

Edit:
I have just installed the fresh copy of rpi os to the new memory card. Got all the same apps that I have on ubuntu vm and configured it the same way with same users. External storage works.
So it is not my configuration since that is very basic, but somewhere deeper.

Hello,

I am not sure, but I have seen during my experience of running Snap Nextcloud, may be due to it’s confinement limitations, external storage must be mounted to either /mnt or /media location. It wont access anything outside those two locations as external storage…

Check if your external mount is within those two locations.

Thanks.

It is mounted to /mnt.
Just for fun, I have tried moving it to /media as well, but it stays the same

I’m guessing it’s because you’re using a mix of supported and unsupported distros. Snaps are not actually cross-distro in that confinement doesn’t work the same everywhere.

1 Like

Ok, thanks for that reply, that is definately news to me.
Lets forget about the rpi os for a moment, can you tell me the point of connect removable media and its use in the ubuntu as the supported distro?

Focusing on ubuntu: yes. You should be able to connect the removable-media interface and you will gain access to the /media and /mnt directories on the host. Each directory that makes up the path you’re wanting to use as the data directory (i.e. /, /mnt, /mnt/razmena and so on) will need to be owned by root.

Being owned by root really makes no sense to me. It is quite limiting. It works only in the case of the whole drive being used by nextcloud only and not being accessed by or from anywhere else.

I would asume that external storage is not exclusive to root, otherwise it would be either internal or useless as external.
I am trully sorry this may sound rude, but i simply cannot accept that as the designed feature.
That means that no matter the location, nextcloud wil not see any file not owned by root.

Fair enough.

I have managed to get a workaround for this. Quite a fun and silly thing, but it works.
I have added the external storage as SFTP. host is “localhost”, root (directory) is /mnt/whatever.

Because my main ubuntu user has a lot of privileges, I have created a new dummy user and used that for auth. Not only that it can see the /ext but it can see everything that the users member can if i need it.
The only thing is that I am not sure if SFTP is maybe a little slower and if it is heavy on the resources.
Not that the speed matters much as the main intention of NC is access from outside the local network over internet and the main limit will be my home internet upload speed.

I will have to check if switching to FTP is ok, since it is not being accessed over network, only localy within that one VM.

In any case, one way or another, this is solved.

This sounds like a recursion problem. You can fix that by adding the -R parameter to your commands. E.g. chown -R root.

It would be impossible to keep that up in my case as the external device is part of the SMB share.

  1. As soon as files are owned by root, no other SMB user has access to it.
  2. SMB is used by torrent client, backup client and users, each of which creates files with their ownership so the initial setup would be shortlived
1 Like

Another update. After using SFTP as external storage, as I suspected, it destroys the performance. Upload and download are somewhat OK, but videos are impossible to play. Downloading larger files is insanely slow.
I have been tinkering again with many settings and found a compromise in giving permission to others. For folders it is r-x and for files it is r–. My samba dir mask is 775 and create mask 754.
In this case, ownership has no effect. Neither folders nor files have to be owned by root.
Actually, changing ownership to root does not help at all in my case. Also, putting root to users group does nothing.

A solution that works well for me, is using bindfs. I have local folders (not owned by root) mounted to /mnt on startup by adding following lines to /etc/fstab

/drv/video /mnt/video fuse.bindfs mirror=root,create-for-user=media_owner,create-for-group=media_owner 0 0
/drv/docs/documents /mnt/docs fuse.bindfs mirror=root,create-for-user=doc_owner,create-for-group=doc_owner 0 0

the option mirror=root maps the ownership of the mounted location too root, while keeping the original ownership of the source location.
with the create-for- options new files will automatically chown’ed to the owners of the source location.

After adding the /mnt/ location as external storage, i have full read/write access.