debugsqlMinor
Postgresql-Server won't start after moving data directory
Viewed 0 times
postgresqlafterdirectoryservermovingstartwondata
Problem
I am running a local postgresql server (9.5 & 9.6) on my Ubuntu 17.04 machine. After moving my data directories to another hard drive following this guide the server can't start.
I.e. with
The logs for both versions then contain the following:
"Keine Berechtigung" translates to "Permission denied".
gives
```
drwxrwxrwx 5 postgres postgres 4096 Sep 25 21:42 base
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 global
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_clog
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_commit_ts
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_dynshmem
drwxrwxrwx 4 postgres postgres 4096 Sep 25 21:42 pg_logical
drwxrwxrwx 4 postgres postgres 4096 Sep 25 21:42 pg_multixact
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 pg_notify
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_replslot
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_serial
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_snapshots
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 pg_stat
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_stat_tmp
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_subtrans
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_tblspc
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_twophase
-rwxrwxrwx 1 postgres postgres 4 Sep 25 21:
I.e. with
sudo service postgresql restart && sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2017-11-06 10:31:32 CET; 1min 42s ago
Process: 8962 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 8962 (code=exited, status=0/SUCCESS)
Nov 06 10:31:32 HERCULES systemd[1]: Starting PostgreSQL RDBMS...
Nov 06 10:31:32 HERCULES systemd[1]: Started PostgreSQL RDBMS.The logs for both versions then contain the following:
pg_ctl: could not access directory "/media/daveknave/BIGFS/PGSQL/9.5/main": Keine Berechtigung"Keine Berechtigung" translates to "Permission denied".
ls -l /media/daveknave/BIGFS/PGSQL/9.5/maingives
```
drwxrwxrwx 5 postgres postgres 4096 Sep 25 21:42 base
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 global
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_clog
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_commit_ts
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_dynshmem
drwxrwxrwx 4 postgres postgres 4096 Sep 25 21:42 pg_logical
drwxrwxrwx 4 postgres postgres 4096 Sep 25 21:42 pg_multixact
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 pg_notify
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_replslot
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_serial
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_snapshots
drwxrwxrwx 2 postgres postgres 4096 Nov 3 21:07 pg_stat
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_stat_tmp
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_subtrans
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_tblspc
drwxrwxrwx 2 postgres postgres 4096 Sep 25 21:42 pg_twophase
-rwxrwxrwx 1 postgres postgres 4 Sep 25 21:
Solution
Verify the permissions on
Does
Switch user to
Verify the file permissions beneath
and then
If you find that the permissions are not correct in the log file, then run the following command to grant
Caution:
Before you modify all permissions ensure the command works by replacing
Try restarting your PostgreSQL instance again.
/main with ls -l /media/daveknave/BIGFS/PGSQL/9.5/Does
postgres still have access to main? Switch user to
postgres with su - postgres and then navigate through the directory structure /media/daveknave/BIGFS/PGSQL/9.5/main/. Can you navigate past main into base?Verify the file permissions beneath
..../base with the following comamnds:ls -lR /media/daveknave/BIGFS/PGSQL/9.5/main/base > ~/postrgres_main_perm.logand then
vi ~/postrgres_main_perm.logIf you find that the permissions are not correct in the log file, then run the following command to grant
postgres all permissions to the directory ...main/base and all underlying sub-directories:chown -Rv postgres:postgres /media/daveknave/BIGFS/PGSQL/9.5/main/base/Caution:
Before you modify all permissions ensure the command works by replacing
chown -Rv with something less destructive like ls -R or navigate down to the .../main directory and issue the shorter command: chown -Rv postgres:postgres base/. This will ensure you are applying the command to the correct directory.Try restarting your PostgreSQL instance again.
Code Snippets
ls -l /media/daveknave/BIGFS/PGSQL/9.5/ls -lR /media/daveknave/BIGFS/PGSQL/9.5/main/base > ~/postrgres_main_perm.logvi ~/postrgres_main_perm.logchown -Rv postgres:postgres /media/daveknave/BIGFS/PGSQL/9.5/main/base/Context
StackExchange Database Administrators Q#190191, answer score: 7
Revisions (0)
No revisions yet.