Snap install - External Storage (local) configuration

I’ve installed Nextcloud using snap on Ubuntu 16.04. I am trying to configure the external storage (local) but cannot get the permissions correct. On a regular install I set the permissions for www-data but it’s not working for the snappy install.

Well, using strong permissions is probably best any time other than when you’re upgrading. If you have problems with that though, you could always look at this post, for slightly more liberal permissions.

I’ve set the permissions of the local directory to 777 (the one I am pointing to through the External Storage (local) setting in Nextcloud) and still cannot read or write to the directory through Nextcloud. Is there a difference between the user (www-data) on a regular Nextcloud install as compared to a snap install of Nextcloud?

As I understand it, it depends on the Snap. For example, if the maintainer set it up with Apache, it’s going to run under a different user than if they set it u using Nginx. That’s only one example, as they could really have set it up to use any user they wished. That said, there are certain default conventions, which they likely abided by, eg. www-data (Nginx) or http (Apache iirc) as the username,

If I set the permissions to 777 for the target directory then any user should be able to read/write. Why is Nextcloud complaining about permissions if the directory is 777?

The user in a snap is root, but your problem is that you’re probably trying to access data located outside of the snap, which is not allowed unless you run the snap in dev mode, which is not recommended.

1 Like

Thank you for your reply. I had heard that snaps were contained but thought that the ‘Local’ option in Nextcloud would be able to access the data because I get the green OK icon when the path to the data is correct. Thank you for your answer.
The data that I am trying to access is in /home/syncthing_data_location
I am trying to use Nextcloud as a web interface for some Syncthing data.
So the ‘Local’ option in a snap install of Nextcloud is not really a viable option.
I have managed to get it to work via sftp.
Would you recommend this as the best option or is there a better way?

You could ask the snap developer to support SMB/Samba per example.

I’ve needing to use a local external storage for large file sharing which would be impossible with the Snap 12.05 Nextcloud install sitting on my servers SSD filesystem with its data shared folder sitting on a small 256 GB SSD.

This link is the only guide on how to proceed for a Snap Nextcloud installed external storage (local) configuration that I’ve been able to locate and attempt.

Log into your server first and set up an admin account.
Make sure your Nextcloud server is enabled.
$ sudo snap enable nextcloud
Connect the remove-media snap plug so that the Nextcloud server can access your external hard drive.
$ sudo snap connect nextcloud:removable-media
Change the Nextcloud server’s config file to point to the new data directory, so do (I prefer pluma or gedit)
$ vi /var/snap/nextcloud/current/nextcloud/config/config.php
And change the value of “datadirectory” to
’datadirectory’ => ‘/media//<hard_drive_name>/nextcloud_data_directory’,
Now, disable the Nextcloud server.
$ sudo snap disable nextcloud
And move all the data to the new data folder (including hidden files!)
$ sudo mv /var/snap/nextcloud/common/nextcloud/data/* /media//<hard_drive_name>/nextcloud_data_directory
$ sudo mv /var/snap/nextcloud/common/nextcloud/data/.* /media//<hard_drive_name>/nextcloud_data_directory
Set the proper permissions so your Nextcloud server can access the hard drive and not complain:
$ sudo chown -R root:root /media//<hard_drive_name>/nextcloud_data_directory
$ sudo chmod -R 0770 /media//<hard_drive_name>/nextcloud_data_directory
Re-enable your Nextcloud server
$ sudo snap enable nextcloud

However this resulted in the following 'Internal Server Error’
Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

stat(): stat failed for /media/name/seagate_backup2/ at /snap/nextcloud/5627/htdocs/lib/private/Files/Storage/Local.php#135

The External Storage addon icon is a Red block despite following the above instructions. Help, comments, suggestions?

Your instructions were
“$ vi /var/snap/nextcloud/current/nextcloud/config/config.php
And change the value of “datadirectory” to
’datadirectory’ => ‘/media//<hard_drive_name>/nextcloud_data_directory’,”

There appears to be an extra forward slash in your datadirectory path directly compared to my working datadirectory path which has been successfully used on v13.04 down through v12.0x

‘datadirectory’ => ‘/media/somehd/nextcloud_data’,

I have no idea if you copied and pasted the exact config.php data_directory entry you added or not. Also, no way would would your instructions using a double forward slash work on both of the sudo chown and chmod commands which would result on a instant fail on a system to carry out.

This wouldn’t work with the double forward slash marks
$ sudo chown -R root:root /media//<hard_drive_name>/nextcloud_data_directory
$ sudo chmod -R 0770 /media//<hard_drive_name>/nextcloud_data_directory

That would need to be corrected also to
$ sudo chown -R root:root /media/hard_drive_name/nextcloud_data_directory
$ sudo chmod -R 0770 /media/hard_drive_name/nextcloud_data_directory

I also had an issue with adding a local directory as external storage, and web search didn’t show this page…
This one as also a solution, that I’ve used with success :

My configuration Linux Mint 19, Nextcloud by snap (today’s version - 2018-07-28 ).

The behavior I had:

  • green light on the new local external storage, seems good
  • any user click on the directory (not shown in main page, but external storage) : looks like it’s going to open, then fall back to main file page.

Errors in log:

|Error|PHP|filesize(): stat failed for /data/Photos/ at /snap/nextcloud/7655/htdocs/lib/private/LargeFileHelper.php#171|2018-07-28T20:59:53+0200|
|Error|PHP|stat(): stat failed for /data/Photos/ at /snap/nextcloud/7655/htdocs/lib/private/Files/Storage/Local.php#140|2018-07-28T20:59:53+0200|

I used the same solution : see 2nd comment of the github link, by Seferi (with the bind mount).

To save time for other people running into the same issue I suggest an update of the documentation for the local external storage.