How to add an external USB-Drive to Nextcloud?

Hello,
how to add an external USB disk? Is there an easy way to do this via dietpi?
I have connected the hard disk, I have activated external storage in Nextcloud. But unfortunately the hard disk is not displayed.


Sorry for my bad english :wink:

Thor
Run dietpi-drive_manager. There you can mount and/or format the drive if required. Then it should be visible to Nextcloud.
Just note that you need to grant the webserver user permissions to the directory to access, e.g.

mkdir /mnt/my_mount/my_data
chown -R www-data:www-data /mnt/my_mount/my_data

“my_mount” needs to match the actual mount target that you chose in drive manager and “my_data” is an example sub directory that Nextcloud can then read and write to.

Hello,
I have successfully mounted a folder of the NAS on the Raspberry (/mnt/nextcloud). I also set the permissions with:

chown -R www-data:www-data /mnt/nextcloud

But what happens now? I would like to always store the data on the NAS.
Many greetings

Thor
In the admin panel you can now configure external storage > local storage, point to the mount point and add permissions to users to use it.

But if I understood you right now, you want all your data stored on the external drive, not just some? Then the external storage plugin is not the right way and you should directly install the whole Nextcloud data dir onto the external drive.

Actually easiest is to simply move the whole dietpi_userdata there:

  • dietpi-drive_manager > select the external drive > User data

If for some reason you want other data to stay on the root partition, you can alternatively edit /DietPi/dietpi.txt SOFTWARE_NEXTCLOUD_DATADIR=/mnt/nextcloud. But this requires a fresh Nextcloud install (so uninstall it completely and install again).

And third alternative, although I do not recommend it the instance is anyway fresh (so you did no heavy configuration on it): https://help.nextcloud.com/t/howto-change-move-data-directory-after-installation/17170

Hi :slight_smile:,
i have decided for the following variant:

If for some reason you want other data to stay on the root partition, you can alternatively edit /DietPi/dietpi.txt SOFTWARE_NEXTCLOUD_DATADIR=/mnt/nextcloud. But this requires a fresh Nextcloud install (so uninstall it completely and install again).

But now i get:

DietPi-Software: ncc maintenance:install

  • Exit code: 1
  • DietPi version: v6.24.1 (MichaIng/master) | HW_MODEL:3 | HW_ARCH:2 | DISTRO:4
  • Image creator: DietPi Core Team
  • Pre-image: Raspbian Lite

Log file contents:
Can’t create or write into the data directory /mnt/nextcloud

Unable to continue, DietPi-Software will now terminate.

I try:

chown -R www-data:www-data /mnt/nextcloud

But it didn’t help. Many thanks already times for your help :slight_smile:

Edit: I’ve just seen that nextcloud has been installed and works so far, but does not use the /mnt/nextcloud directory. What can i do?

I guess I didn’t give the rights to the right user. What is the name of the nextcloud user?

Thor
Sorry for the missing reply. I’ll add an automated pre-creation and chowning of the target dir and try if current Nextcloud installs succeed with this as expected:

mkdir -p $datadir
chown -R www-data:www-data $datadir

www-data is btw the correct user.

Ah lol, this is already done: https://github.com/MichaIng/DietPi/blob/dev/dietpi/dietpi-software#L7328-L7329
Hmm very strange, no idea why it then fails, besides, is this an external drive? If yes, does it even support UNIX perissions?

chown -R www-data:www-data /mnt/nextcloud
ls -l /mnt/nextcloud

If the second command still shows root root, then it obvously does not, e.g. (ex)FAT, or a custom NTFS mount which does not contain the “permissions” mount option.