9

I installed nextcloud on my raspberrypi 3 using this link. Everything is working pretty well except I don't like the UX of having all the extra storage space coming from the "External Storage" add-in, since it means that everyone now has to know to put all of their files in a designated folder.

It seems like I should just be able to tell nextcloud to use the external harddrive as the data-directory location (without the external storage add-in) and all will be well and good... and it seems like in theory that works fine. But, since it's installed as a snap, it seems like the snap doesn't have access to that part of my filesystem and thus it doesn't work.

I was wondering if anyone had any suggestions. Should I mount the harddrive inside the snap's writable area? Is it possible to give the snap access to the harddrive?

12

First of all, I should probably mention that this isn't really a support forum for the Nextcloud snap. If you have issues with it you can log a bug against it.

That said, someone already did, with the solution given here.

To quickly summarize here: you're right, this should be possible, and it is. However, by default the Nextcloud snap doesn't have permission to access removable media (as mentioned in its README).

So, the steps given are:

  1. Connect the removable-media plug: sudo snap connect nextcloud:removable-media.
  2. Connecting that interface gives Nextcloud permission to access things in /media/, so you can edit /var/snap/nextcloud/current/nextcloud/config/config.php and make sure the datadirectory is pointing to the right place.
  3. Disable the snap: sudo snap disable nextcloud
  4. Move (or copy) the current data directory to the new location: sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data.
  5. Re-enable the snap: sudo snap enable nextcloud.

Now you don't need to bother with the external media solution: all of Nextcloud's data will be there.

Note that this only covers the raw data (e.g. files) hosted by Nextcloud. The database and apps are still in /var/snap/nextcloud/current/. I suggest you leave them there.

  • This worked great! I swear, I did do a decent amount of searching and did not find your linked post. The connect ... removable-media is the piece I didn't know about; that's exactly what I was looking for and very helpful. It seems like a good entry for the snapcraft faq. Apologies for posting this in the wrong spot. Placing a bug report seemed silly when I didn't actually find a bug. – Matt Feb 12 '17 at 22:14
  • Oh no apology necessary! This should really be covered in the Nextcloud snap's README, or perhaps its wiki. – Kyle Feb 13 '17 at 6:07
  • 3
    Another thing to mention here is that there could be a permission issue on files as nextcloud server still runs as root, while we might want to use other permissions to files (I'm using nextcloud as a syncthing front-end). To fix this, initially I was using the trick of adding an sftp storage pointing to the server itself and accessing as the wanted user so using 127.0.0.1 as host and the file owner as the user with a generated ssh key. But this wasn't the best choice. Using bindfs instead with something like bindfs --map=ubuntu/root:@ubuntu/@root, does instead the wanted job. – Treviño May 6 '18 at 2:06
  • After I move the directory I got "UniqueConstraintViolationException\",\"Message\":\"An exception occurred while executing 'INSERT INTO oc_filecache...". I hadn't added any files to it, just a clean install of the snap, created the admin users and one login before moving the directory. Any clue? – Giox Nov 4 '18 at 0:52
  • nextcloud snap + syncthing - bindfs entry in fstab is only sustainable way I made this work. Nextcloud snap not using the permissions of the actual user is painful. – Jack Wasey Aug 23 at 12:21
0

Use 'stop' instead of 'disable' otherwise you won't be able to edit config.php.

  1. Enable external storage for snap: sudo snap connect nextcloud:removable-media

  2. Stop nexcloud snap: sudo snap stop nextcloud

  3. Update storage location: sudo vim var/snap/nextcloud/current/nextcloud/config/config.php

change data location:

'datadirectory' => '/media/storage/data',

  1. Move the data directory to the storage device: sudo mv /var/snap/nextcloud/common/nextcloud/data /media/storage/

  2. Start nextcloud snap: sudo snap start nextcloud

New contributor
jonathonp is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.