Skip to content

Wiki Change data directory

scubamuc edited this page May 22, 2024 · 26 revisions

Change Nextcloud snap data directory

1. Create and mount data directory

Removable media can be any device (e.g. external-disk-partition, NFS-network mount, ZFS-device, SSHFS-network mount etc.). The device should be available at system boot and mounted to /media/ or /mnt/ via /etc/fstab.

Tipp: Ensure USB-boot is disabled in BIOS or use the --nofail option in /etc/fstab for headless boot, especially when connecting an external USB-device.

Tipp: Recommend creating a dedicated directory in /media/MYDIRECTORY/ or /mnt/MYDIRECTORY/ and mounting the dedicated directory in /etc/fstab instead of Ubuntu's "automount" /media/$USER/DEVICE/ directory.

2. Connect media to snap

Removable media must be mounted to either /media or /mnt as root with root permissions and connected to Snap!

sudo snap connect nextcloud:removable-media

common error message when media is not connected to Snap

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.

3. Edit configuration file config.php

See editing configuration file config.php

Change data directory procedure a) move or b) define

The procedure to a) move or b) define the data directory in Nextcloud snap is different when an admin-user exists or an admin-user still needs to be created:

a) Move data directory after installation (admin-user exists) in /var/snap/nextcloud/current/nextcloud/config/config.php

Example: /var/snap/nextcloud/current/nextcloud/config/config.php

 // ...
 'datadirectory' => '/media/nextcloud/data',
 // ...

OR

b) Define data directory before installation (admin-user needs to be created) in /var/snap/nextcloud/current/nextcloud/config/autoconfig.php

Example: /var/snap/nextcloud/current/nextcloud/config/autoconfig.php

 // ...
'directory' => '/media/nextcloud/data',
// ...

Tip: Ensure installation is completed and admin-user is created before rebooting

4. Path to data directory

By default, the data directory in Nextcloud snap is .../data!

'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data'

So regardless which procedure is used, the path to the data directory must include the complete path including .../data because this is where the required .ocdata file is located.

Common error message for incorrect path in config file

Error
Your data directory is invalid.

Ensure there is a file called ".ocdata" in the root of the data directory.

Connecting a ZFS device?**

Zpools may be bind mounted to accomplish data access by the snap

For example, create a new directory (e.g. mkdir -p /mnt/zpool_nc)

Depending on where your zpool exists (e.g. /pool/tank0), you can create a bind mount to allow the snap to acces/manage your data

mount -o bind /pool/tank0 /var/snap/nextcloud/common/nextcloud/data

see also path to data directory

Clone this wiki locally