nextcloud snap with data-directory on external harddrive

A bug was logged against the Nextloud snap for this issue, with the solution given here. It's now a wiki entry as well.

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.

Note: if you have issues with the Nextcloud snap, you can log a bug against it.


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