Truenas: data directory "/var/lib/postgresql/data" has wrong ownership

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.4
  • Operating system and version (e.g., Ubuntu 24.04):
    • Truenas Scale 25.04.0
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • yesterday when I wrecked my permission while creating another dataset
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • ?
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

I installed NextCloud 3 days ago after a tutorial on youtube, I set www-data as owner for the datasets I created. Except some problems I was working on resolving (!cron not started since, image preview logged some errors, etc.), everything worked pretty fine.
Yesterday I added a few datasets and wasn’t careful enough, and all permissions changed from POSIX to NFS4. Afterwards Nextcloud container wasn’t starting anymore.
I changed the permissions back to POSIX and added users/groups: www-data, netdata and docker. Still Nextcloud isn’t starting.

My Truenas Dataset setup looks like this:

  • apps(ssd)
    • applications
      • nextcloud
        • userdata
        • appdata
        • postgresdata
      • otherapp
      • otherapp
  • mainpool(hdds)

Log entries

app_livecycle.log says:
…
Container ix-nextcloud-postgres-1 Waiting
Container ix-nextcloud-redis-1 Waiting
Container ix-nextcloud-permissions-1 Exited
Container ix-nextcloud-postgres-1 Error
Container ix-nextcloud-redis-1 Healthy
dependency failed to start: container ix-nextcloud-postgres-1 is unhealthy

sudo docker logs ix-nextcloud-postgres-1 says:
2025-05-15 17:59:14.282 UTC [1] FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
2025-05-15 17:59:14.282 UTC [1] HINT: The server must be started by the user that owns the data directory.
chmod: changing permissions of ‘/var/lib/postgresql/data’: Operation not permitted

I already tried to ‘sudo chown -cR www-data:www-data /var/lib/postgresql/data’ myself in the truenas bash… but that directory does not exist. So I guess its somewhere docker internal… But I dont know how to get there.

Thanks in advance for your help, I hope provided information is sufficient.

Alright, after hours of searching and scratching my head, i found that the “postgresdata” dataset needs netdata:netdata as owner.

I navigated to datasets, opened the POSIX ACL for postgresdata and applied the new owner there. Now nextcloud is starting up again.