Nextcloudpi cannot create data dir on external usb harddrive

I managed to setup Nextcloudpi using the below command in my Raspberry pi 3 running on the latest version of Raspbian

curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash

Upon configuring I want data directory to be moved to my usb hard drive connected to Raspberry pi 3. I followed this guide where I:

  1. applied nc-format-USB
  2. enabled nc-automount
  3. Mounted the usb in /media/harddisk1/ncdata with www-data as both user and group.
  4. chmod 777 to harddisk1 as well as all the files and folders in its subdirectories
  5. When I put this path /media/harddisk1/ncdata into nc_datadir I get the below error

Provide details please on how you created that directory and how it was mounted?

Also output of comands:

sudo ls -lh /media

df -h

Also run:

sudo ncp-report

and post via pastebin.com or similar, no screenshots please, thank you.

Suggest you try removing the dir /ncdata and recreating it with:

sudo rm -rf /media/harddisk1/ncdata
sudo btrfs subvolume create /media/harddisk1/ncdata

and try again

Never chmod 777 to a mountpoint, it is a security risk and will likely mess things up

I created the directory ncdata using the mkdir command. The ls -l outputs the followings

root@raspberrypi:/media/harddisk1# ls -l
total 0
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:48  Backup
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:47 'Hidden Dimsum 2900'
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:47 'Hidden Dimsum Nytorv'
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:46 'Home Page'
drwxrwxrwx 1 www-data www-data 90 Dec 24 08:39  ncdata
drwxrwxrwx 1 www-data www-data 12 Dec 24 09:15  ncdata-12-24-20
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:24  Pictures
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:46 'Video Projects'

Then I mounted it using the command

mount /dev/sda1 /media/harddisk1/

sudo ls -lh /media outputs the followings

root@raspberrypi:/media/harddisk1# sudo ls -lh /media

total 160K

drwxr-xr-x 6 www-data www-data 4.0K Dec 24 08:45 appdata_ocqhfn1rq0gr

drwxrwxrwx 1 www-data www-data 192 Dec 24 09:26 harddisk1

-rw-r----- 1 www-data www-data 135K Dec 24 09:21 nextcloud.log

df -h outputs

root@raspberrypi:/media/harddisk1# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.0G  2.9G  3.8G  43% /
devtmpfs        430M     0  430M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M  7.4M  456M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   55M  198M  22% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/sda1       932G  5.8M  930G   1% /media/harddisk1

sudo ncp-report outputs

This command worked fine
sudo rm -rf /media/harddisk1/ncdata

This command sudo btrfs sub-volume create /media/harddisk1/ncdata output error
btrfs: unknown token 'sub-volume'

my bad, sorry, no - in subvolume

Ok this time the create subvolume worked. Should the user and group be changed to www-data? I

root@raspberrypi:/media/harddisk1# sudo btrfs subvolume create /media/harddisk1/ncdata
Create subvolume '/media/harddisk1/ncdata'
root@raspberrypi:/media/harddisk1# ls -l
total 0
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:48  Backup
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:47 'Hidden Dimsum 2900'
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:47 'Hidden Dimsum Nytorv'
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:46 'Home Page'
drwxr-xr-x 1 root     root      0 Dec 24 10:30  ncdata
drwxrwxrwx 1 www-data www-data 12 Dec 24 09:15  ncdata-12-24-20
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:24  Pictures
drwxrwxrwx 1 www-data www-data  0 Dec 24 07:46 'Video Projects'

It worked this time

no, nc-datadir will/should take care of setting it up right

So the learning here is that creating a directory inside the /media/harddisk1/ncdata should be done using the btrfs command? Simply creating it using mkdir is wrong?

Yes, but nc-datadir usually, takes care of that, it failed a few times, as the directory was already there and also not empty, still writing some data, adding the date to name.

When not already existing, it will detect btrfs and use subvolume create, to create it.

One can/should always view what any ncp app does at Github