title: Permission denied when creating tablespace in postres
body: <p>I'm trying to set up a postgres tablespace on a secondary volume on a fresh installation of Ubuntu 16.04. My primary volume has only 60GB on it and I need a restore a ~55GB database. I'm using a fresh install of postgresql-9.5.</p>
  
  <p>I made the user postgres a super admin so that it would be able to chmod whatever it wants (I know this is not recommended, but I'm getting a little desperate).</p>
  
  <pre><code>sudo usermod -aG sudo postgres
  </code></pre>
  
  <p>As user postgres, I did the following.</p>
  
  <p>I've created a folder on my secondary drive (named postgres_data) and set owner to postgres.</p>
  
  <pre><code>postgres@Eli:/media/rp3/ExtraDrive1$ ls -lisa
  total 28
         2  4 drwxrwxrwx+ 4 root     root      4096 Nov  9 07:46 .
    262146  4 drwxr-x---+ 3 root     root      4096 Nov  9 05:39 ..
        11 16 drwx------  2 root     root     16384 Nov  2 08:14 lost+found
  10485761  4 drwxrwxr-x  3 postgres postgres  4096 Nov  9 07:46 postgres_data
  </code></pre>
  
  <p>I then created a nested folder (named data), also owned by postgres. I did this because I read that the user postgres must own not just the folder I want the tablespace in, but the folder containing that folder.</p>
  
  <pre><code>postgres@Eli:/media/rp3/ExtraDrive1/postgres_data$ ls -lisa
  total 12
  10485761 4 drwxrwxr-x  3 postgres postgres 4096 Nov  9 07:46 .
         2 4 drwxrwxrwx+ 4 root     root     4096 Nov  9 07:46 ..
  10485762 4 drwxrwxr-x  2 postgres postgres 4096 Nov  9 07:46 data
  </code></pre>
  
  <p>I connected to postgres as user postgres and attempted to create a tablespace:</p>
  
  <pre><code>create tablespace mappify_data location '/media/rp3/ExtraDrive1/postgres_data/data';
  </code></pre>
  
  <p>But I got a permissions error:</p>
  
  <pre><code>create tablespace mappify_data location '/media/rp3/ExtraDrive1/postgres_data/data';
  </code></pre>
  
  <p>I've tried changing permissions with chmod 700, changing ownership to postgres:postgres with chown, and creating the folders as the user postgres, but all yield the same result. </p>
  
  <p>I'd appreciate any advice I could get. I'm at my wits' end :(</p>