How to add an external USB-Drive to Nextcloud?

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
Thor
Posts: 16
Joined: Thu May 23, 2019 9:02 pm

How to add an external USB-Drive to Nextcloud?

Post by Thor »

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.
external.PNG
Sorry for my bad english ;)
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by MichaIng »

@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.

Code: Select all

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.
Thor
Posts: 16
Joined: Thu May 23, 2019 9:02 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by Thor »

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

Code: Select all

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
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by MichaIng »

@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-chan ... tion/17170
Thor
Posts: 16
Joined: Thu May 23, 2019 9:02 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by Thor »

Hi :-),
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:

Code: Select all

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

But it didn't help. Many thanks already times for your help :)

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?
Thor
Posts: 16
Joined: Thu May 23, 2019 9:02 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by Thor »

I guess I didn't give the rights to the right user. What is the name of the nextcloud user?
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to add an external USB-Drive to Nextcloud?

Post by MichaIng »

@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:

Code: Select all

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 ... 7328-L7329
Hmm very strange, no idea why it then fails, besides, is this an external drive? If yes, does it even support UNIX perissions?

Code: Select all

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.
Post Reply