Correct chown and chmod for /platformdata, /boxdata, and /appdata After Changing Default Data Directory
-
Hi everyone,
We recently changed the Default Data Directory in Cloudron, but it ended up causing permission issues, so we had to revert the changes and manually adjust the permissions. Since then, some services, including PostgreSQL, are no longer working correctly.
For example, PostgreSQL fails to start with the following error:
Feb 19 13:42:15 ==> Detected existing installation Feb 19 13:42:15 ==> Copying updated config Feb 19 13:42:15 ==> Updating existing postgresql Feb 19 13:42:15 pg_ctl: could not access directory "/var/lib/postgresql/14/main": Permission denied
We suspect that some file ownership or permissions might still be incorrect, especially in the following directories:
/platformdata
/boxdata
/appsdataCould someone confirm the correct chown and chmod settings for these directories to ensure Cloudron operates properly?
Thanks in advance!
-
G girish marked this topic as a question
-
As a default, everything is owned by
yellowtent
user.However, subdirectories inside those paths are mounted into app and service containers. Each container has it's own user space and will change the ownership of the files as needed.
For example, platformdata/postgresql will be used by the postgres container . All the start scripts of containers, will change the ownership of the data. For example, the postgres container already does
chown -R postgres.postgres
on start up.Feb 19 13:42:15 pg_ctl: could not access directory "/var/lib/postgresql/14/main": Permission denied
Haven't seen this one before. Can you check the permissions of
/home/yellowtent/platformdata/postgresql
? -
This is how my directory looks. I think in your case there is some issue with chmod and not chown related.
root@my:/home/yellowtent/platformdata# ls -ln postgresql/ total 4 drwxr-xr-x 3 808 808 4096 Jan 3 17:42 14 root@my:/home/yellowtent/platformdata# ls -ln postgresql/14 total 4 drwx------ 20 106 109 4096 Feb 5 13:55 main root@my:/home/yellowtent/platformdata# ls -ln postgresql/14/main total 104 -rw------- 1 106 109 3 Jan 3 17:42 PG_VERSION drwx------ 6 106 109 4096 Feb 18 09:00 base -rw-r--r-- 1 106 109 691 Jan 3 17:42 custom.conf drwx------ 2 106 109 4096 Feb 17 11:39 global drwx------ 2 106 109 4096 Jan 3 17:42 pg_commit_ts drwx------ 2 106 109 4096 Jan 3 17:42 pg_dynshmem -rw------- 1 106 109 811 Feb 5 13:55 pg_hba.conf -rw------- 1 106 109 1636 Jan 3 17:42 pg_ident.conf drwx------ 4 106 109 4096 Feb 18 09:05 pg_logical drwx------ 4 106 109 4096 Jan 3 17:42 pg_multixact drwx------ 2 106 109 4096 Jan 3 17:42 pg_notify drwx------ 2 106 109 4096 Jan 3 17:42 pg_replslot drwx------ 2 106 109 4096 Jan 3 17:42 pg_serial drwx------ 2 106 109 4096 Jan 3 17:42 pg_snapshots drwx------ 2 106 109 4096 Feb 5 13:55 pg_stat drwx------ 2 106 109 4096 Feb 19 15:20 pg_stat_tmp drwx------ 2 106 109 4096 Feb 16 22:01 pg_subtrans drwx------ 2 106 109 4096 Jan 3 17:42 pg_tblspc drwx------ 2 106 109 4096 Jan 3 17:42 pg_twophase drwx------ 4 106 109 4096 Jan 3 17:42 pg_vectors drwx------ 3 106 109 4096 Feb 17 11:06 pg_wal drwx------ 2 106 109 4096 Jan 3 17:42 pg_xact -rw------- 1 106 109 88 Jan 3 17:42 postgresql.auto.conf -rw------- 1 106 109 968 Feb 5 13:55 postgresql.conf -rw------- 1 106 109 96 Feb 5 13:55 postmaster.opts -rw------- 1 106 109 98 Feb 5 13:55 postmaster.pid
-
This is how my directory looks. I think in your case there is some issue with chmod and not chown related.
root@my:/home/yellowtent/platformdata# ls -ln postgresql/ total 4 drwxr-xr-x 3 808 808 4096 Jan 3 17:42 14 root@my:/home/yellowtent/platformdata# ls -ln postgresql/14 total 4 drwx------ 20 106 109 4096 Feb 5 13:55 main root@my:/home/yellowtent/platformdata# ls -ln postgresql/14/main total 104 -rw------- 1 106 109 3 Jan 3 17:42 PG_VERSION drwx------ 6 106 109 4096 Feb 18 09:00 base -rw-r--r-- 1 106 109 691 Jan 3 17:42 custom.conf drwx------ 2 106 109 4096 Feb 17 11:39 global drwx------ 2 106 109 4096 Jan 3 17:42 pg_commit_ts drwx------ 2 106 109 4096 Jan 3 17:42 pg_dynshmem -rw------- 1 106 109 811 Feb 5 13:55 pg_hba.conf -rw------- 1 106 109 1636 Jan 3 17:42 pg_ident.conf drwx------ 4 106 109 4096 Feb 18 09:05 pg_logical drwx------ 4 106 109 4096 Jan 3 17:42 pg_multixact drwx------ 2 106 109 4096 Jan 3 17:42 pg_notify drwx------ 2 106 109 4096 Jan 3 17:42 pg_replslot drwx------ 2 106 109 4096 Jan 3 17:42 pg_serial drwx------ 2 106 109 4096 Jan 3 17:42 pg_snapshots drwx------ 2 106 109 4096 Feb 5 13:55 pg_stat drwx------ 2 106 109 4096 Feb 19 15:20 pg_stat_tmp drwx------ 2 106 109 4096 Feb 16 22:01 pg_subtrans drwx------ 2 106 109 4096 Jan 3 17:42 pg_tblspc drwx------ 2 106 109 4096 Jan 3 17:42 pg_twophase drwx------ 4 106 109 4096 Jan 3 17:42 pg_vectors drwx------ 3 106 109 4096 Feb 17 11:06 pg_wal drwx------ 2 106 109 4096 Jan 3 17:42 pg_xact -rw------- 1 106 109 88 Jan 3 17:42 postgresql.auto.conf -rw------- 1 106 109 968 Feb 5 13:55 postgresql.conf -rw------- 1 106 109 96 Feb 5 13:55 postmaster.opts -rw------- 1 106 109 98 Feb 5 13:55 postmaster.pid
After applying this 4 commands, It is working properly again, all systems are 🟢.
chown -R 106:109 /home/yellowtent/platformdata/postgresql/14/main
chmod -R 700 /home/yellowtent/platformdata/postgresql/14/mainchown 808:808 /home/yellowtent/platformdata/postgresql/14
chmod 755 /home/yellowtent/platformdata/postgresql/14Hope that these permissions don't bother us again in the future, and will soon try again to change the Default Data Directory.
Thank you very much for your directory output and help.
-
After applying this 4 commands, It is working properly again, all systems are 🟢.
chown -R 106:109 /home/yellowtent/platformdata/postgresql/14/main
chmod -R 700 /home/yellowtent/platformdata/postgresql/14/mainchown 808:808 /home/yellowtent/platformdata/postgresql/14
chmod 755 /home/yellowtent/platformdata/postgresql/14Hope that these permissions don't bother us again in the future, and will soon try again to change the Default Data Directory.
Thank you very much for your directory output and help.
-
G girish has marked this topic as solved
-
@rnphil did you get a chance to see the permissions before you ran the commands? wonder what went wrong.
When we initially changed the default data directory and restarted the entire Cloudron server, something went wrong. As a hotfix, we applied some basic permissions, which probably broke PostgreSQL. However, we don’t know which permissions were wrong, as I didn’t log them at the time.
This morning, we tried changing the default data directory again, but instead of restarting the whole Cloudron, we restarted all services individually, and this time we didn’t get any errors.