I just mounted an external HD for store my new tablespace.
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 denied
What I am missing?
ls -ln /mnt/DB/postgres
returns:
demisc@vostro /mnt/DB $ ls -ln /mnt/DB/postgres/
total 0
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.