title: PostgreSQL create tablespace no permission
body: <p>I've got a problem when I create tablespace for PostgreSQL.  The following are the steps:</p>
  
  <ol>
  <li><code>mkdir /postgres</code></li>
  <li><code>chown postgres.postgres /postgres</code></li>
  <li><code>su - postgres</code></li>
  <li><code>psql</code></li>
  <li><code>create tablespace p1 location '/postgres'</code></li>
  </ol>
  
  <p>In this step I got a error:</p>
  
  <pre><code>could not set permissions on directory "/postgres": Permission denied
  </code></pre>
  
  <p>The directory ownership is correct:</p>
  
  <pre><code>[root@dev ~]# ls -la /postgres  
  总用量 8  
  drwxr-xr-x.  2 postgres postgres 4096 12月  2 13:17 . 
  dr-xr-xr-x. 28 root     root     4096 12月  3 06:57 .. 
  </code></pre>
  
  <p>the user is <code>postgres</code>  </p>
  
  <pre><code>[root@dev contrib]# ps -ef|grep postgres  
  postgres  1971     1  0 08:21 ?        00:00:01 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
  </code></pre>
  
  <p>I'm running on CentOS.</p>
  
  <p>fix: 
  setenforce 0</p>