snippetsqlMinor
Postgres not being able to create a tablespace
Viewed 0 times
tablespacecreatepostgresbeingnotable
Problem
I just mounted an external HD for store my new tablespace.
I gave all the necessary permissions so that posgres could create the new ts in
Happens that when running the create tablespace command I get the following:
What I am missing?
returns:
Everything looks good. There is no reason why postgres user can not create the tablespace. If i switch to postgres and try to create file or dir in the path it works fine.
postgres@vostro ~ $ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb1 480589520 71580 456082280 1% /mnt/DB
postgres@vostro ~ $ ls -l /mnt/DB/
total 4
drwxrwxrwx 2 postgres postgres 4096 May 25 17:02 postgres
demisc@vostro /mnt $ mount | grep -i sdb1
/dev/sdb1 on /mnt/DB type ext4 (rw,nosuid,nodev,relatime,data=ordered)I gave all the necessary permissions so that posgres could create the new ts in
/mnt/DB/postgres. Here is the user groups:postgres@vostro ~ $ id
uid=123(postgres) gid=131(postgres) groups=131(postgres),112(ssl-cert),1000(demisc)Happens that when running the create tablespace command I get the following:
postgres=# create tablespace ts_project location '/mnt/DB/postgres';
ERROR: could not set permissions on directory "/mnt/DB/postgres":
Permission deniedWhat I am missing?
ls -ln /mnt/DB/postgresreturns:
demisc@vostro /mnt/DB $ ls -ln /mnt/DB/postgres/
total 0Everything looks good. There is no reason why postgres user can not create the tablespace. If i switch to postgres and try to create file or dir in the path it works fine.
Solution
I just found a solution. I changed the permission of
Now it worked the creation of the ts
Community Wiki answer created from a comment left by the question author.
Community wiki posts have been donated to the community in hopes that others will edit them to keep them up to date, to add useful information, and generally improve their quality.
/mnt/DB/postgres to 700:postgres@vostro /mnt/DB $ ls -l
total 4
drwx------ 3 postgres postgres 4096 May 25 17:46 postgresNow it worked the creation of the ts
postgres@vostro /mnt/DB/postgres $ ls -l
total 4
drwx------ 2 postgres postgres 4096 May 25 17:46 PG_9.5_201510051Community Wiki answer created from a comment left by the question author.
Community wiki posts have been donated to the community in hopes that others will edit them to keep them up to date, to add useful information, and generally improve their quality.
Code Snippets
postgres@vostro /mnt/DB $ ls -l
total 4
drwx------ 3 postgres postgres 4096 May 25 17:46 postgrespostgres@vostro /mnt/DB/postgres $ ls -l
total 4
drwx------ 2 postgres postgres 4096 May 25 17:46 PG_9.5_201510051Context
StackExchange Database Administrators Q#174615, answer score: 3
Revisions (0)
No revisions yet.