Unable to place the nc-datadir on external ssd

Building a new NextCloudPi server, using an external USB-based SSD as the data directory for the server, I cannot get the external storage to work. Instead, I can upload very small (1k) files, but larger files (8k +) will fail to upload, generating an error like:

Error during upload: Expected filesize of 44754 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 8192 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

Error logs for the file upload issue do not seem to report anything relevant to the issue, but the log generated when trying to use nc-datadir is below, and may be the relevant.

A few things of note:

  • I am using a fresh install of the v1.53.2 image, on a RPi 4 ModelB,
  • I’ve tried to:
    a) Use the wizard that comes on the image, formatting the USB drive and moving the datadir to the USB drive as part of the wizard, and also:
    b) User the wizard to create a working system, and then use nc-datadir to move the datadir after completing the install
  • When I use the default datadir (i.e. install described as (b) above), this error does not occur, and I’m able to upload files > 8k
  • The system does allow me to write larger files to the USB SSD drive (i.e. I can send larger files via scp)

Any help / suggestions appreciated, and thanks to the ncp team for such a great project. I’ve used it a long time and it has provided great utility.

nc-datadir log

[ nc-datadir ] (Fri May 10 20:21:51 BST 2024)
Maintenance mode enabled
moving data directory from /opt/ncdata/data to /media/nextCloudDrive/ncdata…
BTRFS filesystem detected
Create subvolume ‘/media/nextCloudDrive/ncdata’
{“reqId”:“MkhAeDkzVaUjrGyyadNB”,“level”:2,“time”:“2024-05-10T19:22:04+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“”,“url”:“–”,“message”:“Temporary directory /opt/ncdata/data/tmp is not present or writable”,“userAgent”:“–”,“version”:“”,“data”:}
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
Your data directory is invalid.
Ensure there is a file called “.ocdata” in the root of the data directory.

Cannot create “data” directory.
This can usually be fixed by giving the web server write access to the root directory. See Introduction — Nextcloud latest Administration Manual latest documentation

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:167
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once(‘…’)
#2 {main}
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value logfile set to string /media/nextCloudDrive/ncdata/data/nextcloud.log
Nextcloud is in maintenance mode, no apps are loaded.
Commands provided by apps are unavailable.
System config value tempdirectory set to string /media/nextCloudDrive/ncdata/data/tmp
Installing template ‘php/opcache.ini.sh’…
Maintenance mode disabled
Installing template ‘ncp-metrics.cfg.sh’…
The NC data directory has been moved successfully.

It looks like www-data don’t have access to create subfolders there. Consider of below to grant the permission:

sudo chown -R www-data:www-data /media/nextCloudDrive/ncdata

Or you might even need to update the permission of the mounting point.

Hope this could help you back on the right track.

I have resolved this issue by running the nc-limits command after the initial setup, to re-set the max file size to be 10GB. I got the idea to do this by reading this issue on GitHub.

It’s unclear how this incorrect setting in the php.ini comes to be, but it would seem that the implication is; no one would have been able to build a fresh install of ncp from the approved images, and set up to use an external HDD successfully for about a month. Unlikely to help adoption of the platform.

Also, it seems that the issues in the nc-datadir log entries are not relevant to this issue.