Unable to change datadirectory - snap installation Nextcloud Nextcloud Hub 6 (27.1.4)

Support intro

Nextcloud version (eg, 20.0.5): ` Nextcloud Nextcloud Hub 6 (27.1.4)
Operating system and version (eg, Ubuntu 20.04): 22.04.3 LTS
(snap instalaltion by Ubuntu)

  • Apache or nginx version (eg, Apache 2.4.25): replace me
  • PHP version (eg, 7.4): replace me

The issue you are facing: Unable to change data directory and no solution found.
Tried as much tips/solutions as I could get from internet (e.g. editing php cofing files, file permissions etc.) all failed with the error message of “missing .ocdata”. Since this is home internal server, I just add a new disk and change the mount point for /var/snap/nextcloud and eventually I could manae it. But it is not the way I intended. I could not find any text of solusion for “change datadirectory” that in Administration guide / internet community .

Is this the first time you’ve seen this error? (Y/N):

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

PASTE HERE

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

PASTE HERE

Hello,

You may need to do following to change the user data location for snap,

1. External Drive Mounting

Snap can only access /mnt or /media under ubuntu. So if you are using any external drive, make sure that drive is mounted under any of those two locations.

2. Allowing Snap to access outside

By default snap can’t access out side of it’s working environment so you need to first run following command to allow snap nextcloud to access out side of it’s confinement

sudo snap connect nextcloud:removable-media

3. Editing Config / Moving Data

Run following command to edit the config file for manually setting new location,

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php

This will open up Nextcloud configuration file in a CLI text editor. Be very careful, DO NOT change or modify it in anyway apart from one line called “DataDirectory” change the value to → /media/your/external/location or something like /mnt/your/external/location

Press CTRL + X then type Y and press enter to save and exit.

Now move the existing content to new directory,

sudo mv /var/snap/nextcloud/common/nextcloud/data /your/new/location

Reboot the system, it should now start working from the new location. In case you are facing any permission issue, you “may” need to ensure the ownership or the new directory is under root:root and permission to 0770

Refer here for details → Configure Nextcloud snap · nextcloud-snap/nextcloud-snap Wiki (github.com)

Thanks.

1 Like