NexcloudPi crashes a couple of times week, Your data directory is invalid

Hi all

Ive been trying to get NextcloudPi running stable on a Raspberry Pi 4 Model B Rev 1.2 .
A couple of days a week it crashes and I get the message "Your data directory is invalid. Make sure you have the “.ocdata” file in the main directory of your data.

Unable to create “data” directory.".

Nextcloud version 25.0.3
Operating system and version Linux 6.1.21-v8+ aarch64
Apache or nginx version Unkown, how do I find that out?
PHP version 8.1.18

The issue you are facing: Get the error message "“Your data directory is invalid. Make sure you have the “.ocdata” file in the main directory of your data.”

Is this the first time you’ve seen this error? (Y/N):N, happens a couple of times a week, usually every time i add more files to it.

Steps to replicate it:

  1. Just wait and it will happen :slight_smile:

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

	serverinfo	RedisException: Redis server /var/run/redis/redis.sock:0 went away
/var/www/nextcloud/lib/private/Memcache/Redis.php - line 48:

Redis->get()

/var/www/nextcloud/lib/autoloader.php - line 154:

OC\Memcache\Redis->get()

<<closure>>

OC\Autoloader->load()

/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php - line 207:

class_exists()

/var/www/nextcloud/lib/private/legacy/OC_App.php - line 173:

OC\AppFramework\Bootstrap\Coordinator->isBootable()

/var/www/nextcloud/lib/private/legacy/OC_App.php - line 141:

OC_App::loadApp()

/var/www/nextcloud/lib/private/Console/Application.php - line 120:

OC_App::loadApps()

/var/www/nextcloud/console.php - line 99:

OC\Console\Application->loadCommands()

/var/www/nextcloud/occ - line 11:

require_once("/var/www/ne ... p")

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Sorry, new to this, how do I access that?
PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

PASTE HERE

Hi,

let’s check off some easy boxes first:

1 Check that the user running Nextcloud has read and write permissions to the data directory.
ls -la in the directory containing the data directory and verify that the owner and group permissions are set correctly.

2 Make sure that the disk space on the Raspberry Pi is not full.

3 This is probably not the case, but with an old Pi still possible: Check the system for file system errors run the command sudo fsck /dev/sda1 to check the file system for errors.

Cheers

Thanks for reaching out but i need more help :).
I have more or less no experience in Linux.

I cant even figure out how to navigate to my external USB harddrive where all data is stored.
I am willing to learn but maybe in baby steps.

  1. How do I change the drive to my USB, and how can I loose write permissions to that randomly?

  2. The Raspberry has a 32 gig SD card, root has 24 gig left so thats ok.

  3. Its a Raspberry 4 so not an older verison.

And now it crashed again with the same error.
Is it actualy possible to have nextcloud running stable?

To answer your question: Yes it is.

To be honest it will require some knowledge in Linux and all that stuff. You will learn a lot in the beginning with every weird problem you will have.

You tagged your post with “ncp” which means you use nextcloudpi for your device. All docs for this project are at docs.nextcloudpi.com. it will help a lot to read a few articles there.

1 Like

I have found no information regarding my problem, “Your data directory is invalid. Make sure you have the “.ocdata” file in the main directory of your data”

Can you point me in the right direction? Since it works for a while and the suddenly doesnt work it must be something else than write permissions since they dont change by them self? A file doesnt disappear either and the reappear when i reboot the pi.

Best option to start is to check the logs. Please ssh into your machine and type the command ncp-report . copy all the data and post it here

Hi again.

I uploaded some stuff earlier today and after that it crashed again. It seems like it looses the connection to my USB drive for some reason?

NextcloudPi diagnostics

{"reqId":"IZo9sADOjL83f7GW00jk","level":2,"time":"2023-05-13T22:31:44+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"25.0.3.2","data":[]}
NextcloudPi version  v1.52.0
NextcloudPi image    NextCloudPi_RaspberryPi_v1.51.0.img
OS                   Debian GNU/Linux 11. 6.1.21-v8+ (aarch64)
automount            yes
USB devices          none
datadir              /media/myCloudDrive/ncdata/data (doesn't exist)
rootfs usage         3.2G/29G
swapfile             /var/swap
dbdir                /var/lib/mysql
Nextcloud check      error
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
HPB service          down
Postfix service      up
Internet check       ok
Public IPv4          ***REMOVED SENSITIVE VALUE***
Public IPv6          ***REMOVED SENSITIVE VALUE***
Port 80              open
Port 443             open
IP                   ***REMOVED SENSITIVE VALUE***
Gateway              ***REMOVED SENSITIVE VALUE***
Interface            eth0
Certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
Uptime               2days

Nextcloud configuration

{"reqId":"jvsD7WiPT2RchWnxw3pg","level":2,"time":"2023-05-13T22:31:48+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/myCloudDrive/ncdata/data/tmp is not present or writable","userAgent":"--","version":"25.0.3.2","data":[]}
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 https://docs.nextcloud.com/server/25/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('...')
#2 {main}
HTTPd logs

[Sat May 13 00:00:00.935943 2023] [ssl:warn] [pid 900:tid 548542497856] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Sat May 13 00:00:00.938466 2023] [mpm_event:notice] [pid 900:tid 548542497856] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat May 13 00:00:00.938503 2023] [core:notice] [pid 900:tid 548542497856] AH00094: Command line: '/usr/sbin/apache2'

Database logs

tail: cannot open '/var/log/mysql/*.log' for reading: No such file or directory

Nextcloud logs

tail: cannot open '/media/myCloudDrive/ncdata/data/nextcloud.log' for reading: No such file or directory

Looks like the drive is not mounting correctly, maybe the drive or it’s power source are starting to fail.
I’d would likely try to mount it my (Linux) PC to investigate.

Reading this also makes me realize, that you might want to check the power supply of your Pi. Is it powered by the needed voltage? Not enough and it might just kick your USB drive out of the loop for a moment.
I myself do that from time to time, out of bad habit, and just throw an old and skimpy smartphone charger at my Pi, which is not smart of me.

I have power supply that is up to spec but I will try another one just to be sure.
Good input, thanks.

Its a brand new drive.
Can there be some sort of power save on the drive?
I tried to unplug and replug the drive last time but nextcloud didnt find the files.

Is there some command I can use to try to re mount the drive?

It also only happens after I upload new files

Den sön 14 maj 2023 09:50Oliver_Van via Nextcloud community <noreply@nextcloud.com> skrev:

Not a good idea, rather use [this howto] to mount a drive permanently (Mounting an external drive using UUID and fstab | Linux admin junior)

Power save, could slow things down, but should just power back on when uploading files.

To check if and where drives are mounted I use:

sudo df -hT

In Linux to mount a drive one uses

sudo mount /dev/sda1 /media/drivename

But you enabled automount so should not need to manually mount unless you add more drives to your system.

Yesterday I uploaded som more date and after some time teh server crashed again with teh same error.
The command sudo df -hT gave me the following result:

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/root      ext4       29G  3.2G   25G  12% /
devtmpfs       devtmpfs  1.7G     0  1.7G   0% /dev
tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs          tmpfs     759M  1.2M  758M   1% /run
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
/dev/mmcblk0p1 vfat      255M   31M  225M  13% /boot
tmpfs          tmpfs     380M     0  380M   0% /run/user/1000

My external drive isnt there, it is 14TB

After a reboot it looked like this

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/root      ext4       29G  3.2G   25G  12% /
devtmpfs       devtmpfs  1.7G     0  1.7G   0% /dev
tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs          tmpfs     759M  1.2M  758M   1% /run
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
/dev/mmcblk0p1 vfat      255M   31M  225M  13% /boot
/dev/sda1      btrfs      15T   17G   15T   1% /media/myCloudDrive
tmpfs          tmpfs     380M     0  380M   0% /run/user/1000

Son now the external drive is there. So for some reason the external drive is dropped after new data is added to nextcloud

I would look at the system logs in /var/log just after the event.
-rw-r----- 1 root adm 2,1M May 17 10:34 syslog
-rw-r----- 1 root adm 1,5M May 17 10:34 messages
-rw-r----- 1 root adm 1,5M May 17 10:34 kern.log

Run from terminal:

sudo cat /var/log/syslog

And look for error messages

I guess its better to do this after a crash but now when everything is fine i found one error message:
Transfer event TRB DMA ptr not part of current TD ep_index 3 comp_code 1

Didnt take much time for another crash, this time witk no activity in Nextcloud at all

Log here

So it crashed again tonight.
I tried “sudo mount /dev/sda1/media/myCloudDrive”
And got can’t find in /etc/fstab.

How is that possible?

May we have a cat of your fstab file?
cat /etc/fstab