Is there a way to change the data directory nextcloud is using to an external drive mounted on /media/? I obviously don't want everything on my rather small SSD. Thanks!
Oh certainly!
removable-media plug as mentioned in the README in order to grant the snap permission to access external drives./media/my/new/data. Update the Nextcloud config to use it by editing /var/snap/nextcloud/current/nextcloud/config/config.php and making sure the datadirectory setting is pointing to the right place, e.g.:// ...
'datadirectory' => '/media/my/new/data',
// ...
Stop the snap from running for a moment:
$ sudo snap disable nextcloud
Move (or copy) the current data directory to the new place:
$ sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data
Re-enable the snap:
$ sudo snap enable nextcloud
And you should be up and running using external storage for Nextcloud's data.
Thanks for the help, worked like charm!
So, at first this whole thing worked, but now nextcloud complains about a corrupt data directory: Data directory (/media/.cloud) is invalid
Please check that the data directory contains a file ".ocdata" in its root. But .ocdata exists! Furthermore, I get a permission error like Data directory (/media/.cloud) not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. although the permissions are set to 0770 www-data on ubuntu. Ideas?
I changed the ownership of the data directory to root, now it seems to be fixed.
Ah very good. I'm going to go ahead and close this, then :smiley: .
@petwri .. how did you mount the external drive in a persistent way, with snappy ubuntu-core?
still errors saying it can't find the ocdata file for me :/
@jeroen7s where is the drive mounted for you? The removable-media plug only covers /run/media/* and /media/*.
@kyrofa thanks for the swift reply, my drive is currently mounted under /mnt, i can mount it under media if necessary, i'll let you know if it fixes it.
changing mount location from /mnt/hdd0 to /media/hdd0 fixed the issue, though i would like there to be an option to also allow /mnt/XXX to connect to the nextcloud snap.
Good to hear. I'm afraid there's nothing we can do here about accessing /mnt, that's something that would need to be supported in snapd.
@kyrofa I'm going to perform this operation, my removable disk is mounted in /media/sda1 did I move the data directory in /media/sda1/data..? Thanks..:)
I've moved the directory but data files are visible in the GUI and visible also to other users.. How to hide..?
It is possible to access data from /mnt or any arbitrary directory with the snap version of nextcloud.
removable-media plug as mentioned in the README in order to grant the snap permission to access external drives. $ sudo snap connect nextcloud:removable-media
$ sudo mount --bind /mnt/dir_with_contents /media/nextcloud_local_dir
In nextcloud enable the external storage app, then add a local storage with the path /media/nextcloud_local_dir
Profit!
I don't understand how this mount command posted above and below applys to the Snap installed Nextcloud, perhaps you or someone could revisit this more fully to enable me to add the needed external and/or removable-media ability and use on my Snap installed Nextcloud which is loaded onto my server's small SSD 256GB drive.
$ sudo mount --bind /mnt/dir_with_contents /media/nextcloud_local_dir
The Snap Nextcloud data folder is located at /var/snap/nextcloud/common/nextcloud/data
the example removable-media path is located at /media/user-name/seagate_backup2/nextcloud_data_directory
$ sudo snap connect nextcloud:removable-media
Snap Nextcloud installed config.php /var/snap/netcloud/current/netcloud/config updated to
'datadirectory' => '/media/user-name/seagate_backup2/nextcloud_data_directory',
$ sudo chown -fR root /media/user-name/seagate_backup2
$ sudo chown -R root /media/user-name/seagate_backup2/nextcloud_data_directory
$ sudo chmod -R 770 /media/user-name/seagate_backup2/nextcloud_data_directory
sudo snap enable nextcloud
External mount error
There was an error with message: Empty response from the server. Do you want to review mount point config in admin settings page?
@ASmith- did you actually move your original data over, or are you pointing Nextcloud to a now-empty directory?
Hi @kyrofa yes there appears to be conflicting answers on the possible solution which still eludes me in successfully solving this issue.
One uses only the snap removable-media command and then issues the permissions on the removable-media directory file and updates the config.php to the new datadirectory path.
One uses the external storage addon and then placing the local configuration to point to the locally configured media directory file and updating the config.php to the new datadirectory path.
One uses the removable-media command and also the external storage addon set at a local configuration to point to the locally configured media directory file and updating the config.php to the new datadirectory path. I have tried all of them and none of them are working properly for me.
Originally yes I moved all of my original data over to the removable-media drive to a nextcloud_data_directory. The Nextcloud application failed with all the above when the config.php datadirectory was updated to 'datadirectory' => '/media/user-name/seagate_backup2/nextcloud_data_directory',
I copied all the 'data' folder files back to restore full functionality back again to my Snap installed Nextcloud application. I have all the data files in their original location at
/var/snap/nextcloud/common/nextcloud/data
and now also at
/media/user-name/seagate_backup2/nextcloud_data_directory
And now have issued the removable-media command to connect
And have the External storages addon enabled and set for local folder name nextcloud_data_directory, configuration /media/user-name/seagate_backup2/nextcloud_data_directory available currently for the admin@group. There is a Red square icon showing.
Presently the only working config.php datadirectory link is the original Snap installed one
'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
Perhaps someone here that has successfully completed setting up one or more snap Nextcloud installed applications local external storage, removable-media hard drives to function as additional Nextcloud file sharing storage areas could take the time to outline the exact steps and examples to successfully do that.
Looks like the first command would be to make sure removable-media snap is connected.
$ sudo connect nextcloud:removable-media
Next using the admin account enable the External storages 'app' plugin if not already enabled.
then
Shut-down any running instance of Nextcloud on the system
$ sudo snap disable nextcloud
then reset the permissions on the entire hard-drive or just a single folder???
The entire removable-media hard-drive
$ sudo chown -R root:root /media/username/seagate_backup2
or
The removable-media hard-drive folder you intend to use solely for nextcloud file storage?
$ sudo chown -R root:root /media/username/seagate_backup2/nextcloud_data
then reset the permissions on the removable,remote storage folder
$ sudo chmod -R 0770 /media/username/seagate_backup2/nextcloud_data
$ sudo snap enable nextcloud
next change the snap installed nextcloud config.php datadirectory location and/or? the External storages configuration?
original config.php datadirectory entry
'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
to ?
'datadirectory' => '/media/username/seagate_backup2/nextcloud_data',
Where the original data folder is cloned including the 2 invisible files to nextcloud_data
and/or
External storages
Folder name
documents-1
External storage
local
Configuration
/media/username/seagate_backup2/documents-1
Available for
admin (group)
Friends (group)
*
Enable previews
Enable sharing
Neither of these latter explicitly stated commands for the removable media or/and External storage configurations work.
The removable media which includes the updated config.php datadirectory entry to 'datadirectory' => '/media/username/seagate_backup2/nextcloud_data',
Kicks up a 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. (which in snap is located exactly were? ).
The External storages immediately kicks up a 'Red' square icon indicating a configuration error.
stat (): stat failed for /media/username/seagate_backup2 at /snap/nextcloud/5627/htdocs/lib/private/Files/Storage/local-php#135
local-php line 135 is
$statResult = stat($fullPath);
I need help on adding a local External and/or removable storage configuration and ability on this snap installed Nextcloud.
@ASmith- If you just need access to a directory (be it a removable drive or other), just follow my directions above. No need to change permissions or any config files.
SOLVED Although no one pointed out the solution, after inspecting the mounting point on the external local hard drive I was using, I tested moving it from /media/username/seagate_backup2 to /media/seagate_backup2 and using $ sudo gnome-disks to identify the portable USB Hard Drive's UUID and explicitly change to the new mounting point to always mount at that location at start-up the moment that portable hard drive UUID was plugged into the system.
/media/username/seagate_backup2 which I had been constantly attempting and unsuccessfully trying to use included the path often used by portable USB 3.0 based hard-drives and also mentioned in some Nextcloud documents as the syntax to use turned out to be the problem. The problem appears to be a conflict with the local user (username in a path) and the need to be accessing the folders on that device solely as root. Not wanting to add myself to a root group and risk creating superuser only files accidently, I tested the new mount minus the local username normal USB hard-drive mounting point and that solved the 3 day long issue I was having immediately.
External Storage mounting point conflict and resolution
/media/username/seagate_backup2 <--failed due to internal localuser conflicts on the path
/media/seagate_backup2 <-- success
The removable media now also includes the working updated config.php datadirectory entry to 'datadirectory' => '/media/terabyte6/nextcloud_data', <-- success
I'm about 6 days into this and still can't move data directory to external(technically not external-sata) 8tb drive without getting an error when logging back into the nextcloud web interface.
Does ASmiths post solve this or do I defer to OP or do I use Kernels Sanders symlink method? I've tried all methods on the thread using latest NC snap 13 + ubuntu 16, night after night to no avail.
I'm really trying to get the data directory moved to my external 8tb hdd since my ssd is only 120gb.
I could use some clarity on where to point new directory because of the local user path vs not using local user path as ASmith said above is successful.
Yes I am moving the directory with mv command after pointing in config. Done all these steps literally 20 times or more, with all the variations. There has to be a "given" missing here, something noobs don't know or experienced users are assuming everyone knows.
Could someone please point me to "how to move nc data directory for dummies" or noobs? Plz?
Thanks In advance
@DAMONSTA360
Ok, here is a full walk-through from clean Ubuntu to Nextcloud with external (mounted) storage.
$ sudo snap install nextcloud
removable-media plug as mentioned in the README in order to grant the snap permission to access external drives.$ sudo snap connect nextcloud:removable-media
$ sudo fdisk -l
$ sudo mkdir /mnt/external && sudo mount /dev/sdb1 /mnt/external
removeable-media plug allows the nextcloud snap to access.$ sudo mount --bind /mnt/external /media/nextcloud
A in the top right corner and select + Apps. Then click Enable for External storage support.
A again and then click Settings. Under Administration, add a local storage with the path /media/nextcloud.
Thank you kernel sanders
In my situation the 8tb external drive is at sda1 or sda and
the boot drive is at sdb1 or sdb
per your note : _you will be using /dev/sdb1 for the rest of this walk-through_
what is the correct syntax for _sudo mkdir /mnt/external && sudo mount /dev/sdb1 /mnt/external_
meaning; am i simply replacing /dev/sdb1 in the syntax for my drives names sda1? or am i replacing for the word "external" in the syntax as well?
Because i attempted this and received error
jake@jake-desktop:~$ sudo snap connect nextcloud:removable-media
jake@jake-desktop:~$ sudo mkdir /mnt/external && sudo mount /dev/sda1 /mnt/external
mkdir: cannot create directory ‘/mnt/external’: File exists
jake@jake-desktop:~$
Read the error. /mnt/external already exists. The location you mount your drive does not matter. Feel free to replace /mnt/external with /mnt/blueberries or anything else you like. If you are using a "Desktop" Ubuntu OS (i.e. it has a GUI) the drive may already have been mounted automatically by the OS. I assumed you were using Ubuntu server. If the disk was already mounted, find its mount point and use that in place of /mnt/external.
Here you say the location doesn't matter.
_`The location you mount your drive does not matter. Feel free to replace /mnt/external with /mnt/blueberries_
and here your suggesting i insert my mount point of /dev/sda1 into /mnt/external ??
_If the disk was already mounted, find its mount point and use that in place of /mnt/external_
im a little thickheaded here.
if my mount point is dev/sda1 could you help me write the line i am supposed to type please?
could you give me an example using my mount point?
/dev/sda1 is not the mountpoint, but a device file representing partition 1 of sata-disk a, the first sata-disk.
The mountpoint, e.g. the location you mount your drive (/dev/sda1), is commonly something under /media/, e.g. /media/cranberries/ - You can name the directory anything you want, but it should reside under /media/ because that's what the removable-media plug grants permission for. A device (file) can be mounted to multiple mountpoints.
Preferably make it appear somewhere under /media with the first mount, so you can drop the mount --bind command, which does nothing but mirror the mountpoint to the correct location, where it could have been in the first place (iinm).
If you follow the carefully written steps by @kernel-sanders, it will work as expected. Otherwise, come back when it doesn't and tell us something like: "I am stuck at step 37, your how-to says my screen should blink green, instead, it flickers red." I don't want to appear rude, but I think this is not the place to teach you the inner workings of linux.
Hey man, I really am not trying to be mean but you have to be able to figure some basic stuff out on your own or you won't make it very far in tech or life. Try googling for "what is a mount point." Once you understand what a mount point is, determine if it makes sense that /dev/sda1 would/could be a mount point. If you still can't figure it out, come back here.
Oh certainly!
1. Connect the `removable-media` plug as mentioned in the [README](https://github.com/nextcloud/nextcloud-snap/blob/master/README.md) in order to grant the snap permission to access external drives. 2. Decide where you want the new data to live. We'll use `/media/my/new/data`. Update the Nextcloud config to use it by editing `/var/snap/nextcloud/current/nextcloud/config/config.php` and making sure the `datadirectory` setting is pointing to the right place, e.g.:// ... 'datadirectory' => '/media/my/new/data', // ...1. Stop the snap from running for a moment: ``` $ sudo snap disable nextcloud ``` 2. Move (or copy) the current data directory to the new place: ``` $ sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data ``` 3. Re-enable the snap: ``` $ sudo snap enable nextcloud ```And you should be up and running using external storage for Nextcloud's data.
Even in my case is internal storage in /media/my_disks/ and the path changed to 'datadirectory' => '/media/my_disks/data',and the .ocdata exist in /media/my_disks/data:
~$ sudo ls -al /media/my_disks/data/
total 24
drwxrwx--- 5 root root 4096 May 19 10:41 .
drwxr-xr-x 5 root root 4096 May 19 17:00 ..
drwxr-xr-x 7 root root 4096 May 19 10:31 appdata_ocbg0df021yn
drwxr-xr-x 2 root root 4096 May 19 10:41 files_external
-rw-r--r-- 1 root root 324 May 19 10:31 .htaccess
-rw-r--r-- 1 root root 0 May 19 10:31 index.html
-rw-r--r-- 1 root root 0 May 19 10:26 nextcloud.log
-rw-r--r-- 1 root root 0 May 19 10:31 .ocdata
drwxr-xr-x 4 root root 4096 May 19 11:21 mein
But still with this error message
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.
Access to /mnt is now supported but requires snapd version 2.36+
@peterwvj how? If I try and configure /mnt/bigdrive as the data location, even with permissions set, it does not work. The method of using the external storage plugin under /media with a bind mount does work, but this requires all files to be stored in a specific folder belonging to the mount point.
I have snap 2.42 and snapd 2.42 on 18.04
Allowing the snap to access external storage should be sufficient:
~
$ sudo snap connect nextcloud:removable
~
This allows me to use /mnt/md0 as my data storage, see
Yes of course, I'm sorry. New to snaps and nextcloud, and when I tested it first on /mnt I didn't have the removable connected. So I went down the plugin route. But I cleaned up my server, and it works great on /mnt now. So that's stage 1 done :)
No worries! Glad to hear that it worked! Good luck with the remaining stages :)
I have installed nextcloud via snap, made my data location to /media/usbhd/data made everything
sudo nano /etc/fstab
/dev/sda1 /media/usbhd ntfs defaults 0 1
sudo chown -R root:root /media/usbhd/data
sudo chmod -R 0770 /media/usbhd/data
but still I get the message :
"Your data directory is readable by other users
Please change the permissions to 0770 so that the directory cannot be listed by other users."
apparently nobody else has the problem as I have seen, at least not about snap installation
Hi @kyrofa
I think that
sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new/data
should be:
sudo mv /var/snap/nextcloud/common/nextcloud/data /media/my/new
I think this can lead to errors such as "Ensure there is a file called ".ocdata" in the root of the data directory."
@doleron you're correct, that's a mistake. The directions folks should be using are in the wiki, where this error was thankfully fixed.
Most helpful comment
Oh certainly!
removable-mediaplug as mentioned in the README in order to grant the snap permission to access external drives./media/my/new/data. Update the Nextcloud config to use it by editing/var/snap/nextcloud/current/nextcloud/config/config.phpand making sure thedatadirectorysetting is pointing to the right place, e.g.:Stop the snap from running for a moment:
Move (or copy) the current data directory to the new place:
Re-enable the snap:
And you should be up and running using external storage for Nextcloud's data.