Postgresql on external HD I have a set of .csv files many times larger than my hard drive which I would like to load into database tables using postgresql.  (I must keep it locally on an external hard drive due to Data Use Agreement restrictions.)

I would like to tell Postgresql to store the tables I load on the external drive, due to size constraints.

I think I can do this with initdb -D '/Volumes/My Book/2020/', where /Volumes/My Book/2020/ is the path to the folder on the external drive.

I get the error: FATAL:  data directory &quot;/Volumes/My Book/2020&quot; has invalid permissions 2021-01-23 11:21:58.864 EST [4390] DETAIL:  Permissions should be u=rwx (0700) or u=rwx,g=rx (0750).

But ls -l &quot;/Volumes/My Book/&quot; returns (among other lines) drwxrwxrwx@ 1 my_username  staff  1048576 Jan 19 13:29 2020 which looks like the right set of permissions to me.

I tried sudo chown my_username &quot;/Volumes/My Book/2020/&quot;, but I get the same error as before.

I tried sudo chmod a+rwx &quot;/Volumes/My Book/2020/&quot;, and still get the same error.


Can anyone advise me about how to set the permissions correctly?  (Or failing that: maybe I am taking the wrong approach to this problem?)
Thanks!
I'm the OP.  Thanks for the help from those above.  Here is what I ended up doing to solve this problem.  I think this is all of the steps but something could be missing.  (This is via Mac on Catalina.)  Happy to accept any corrections if I forgot a step.

Format the external drive AFPS or GUID via diskutility (using the &quot;view all&quot; command).  (This will delete everything on the drive, so you need a backup.)

After formatting, sudo chmod -R 0750 &quot;/Volumes/your_external_hd_name/  from the command line - this will set the correct permissions.

initdb -D '/Volumes/your_external_hd_name/database/'     # creates a &quot;database cluster&quot;

pg_ctl -D /Volumes/your_external_hd_name/database/ start   # seems to run the cluster

NB: at the above step, if you get an error including the line &quot;Is another postmaster already running on port 5432?&quot;, then run ps -ef | grep postmaster | awk '{print $2}' on the command line, followed by kill &lt;pid1&gt; ... &lt;pidN&gt; for any PIDs which show up.

psql postgres

CREATE DATABASE &lt;database_name&gt;;

\l                                                 # list databases

\c &lt;your_database&gt;                                 # connect to the database

\dt                                                # list tables

CREATE DATABASE &lt;name&gt;;                            # creates w/in the cluster

CREATE TABLE &lt;table&gt;;                              # include some columns

\dt                                                # to check that it was created,  should appear

If you need to undo/correct: DROP TABLE &lt;name&gt;;

\copy &lt;table_name&gt; FROM 'path/to/file';

\q # exit

 pg_ctl stop -D /Volumes/your_external_hd_name/  # seems to be important to prevent database from getting damaged, but I have never disconnected w/out it so I am not 100% sure.